The Standard

The Standard
DeFiHardhat
20,000 USDC
View results
Submission Details
Severity: low
Invalid

`deleteHolder` function implementation incosistency

Summary

The function deleteHolder deletes an address from the array holders, but while deleting the function will replace the item with last item and then pop off the last element of array.

Here are 2 cases that are needed to be considered.

Case - 1:
If Holders are unique atleast according the functionality present in the code, then it is exhaustive to iterate through the loop if the array is long.

Case - 2:
If the holders are not meant to be unique, then there will be high chances of skipping the last item which will be swapped in place of the removing item.

Tools Used

Manual Review

Recommendations

Case - 1:
Holders are unique

function deleteHolder(address _holder) private {
for (uint256 i = 0; i < holders.length; i++) {
if (holders[i] == _holder) {
holders[i] = holders[holders.length - 1];
holders.pop();
+. break
}
}
}

Case - 2:
If Holders are not unique then, use the same logic of deletion as consolidatePendingStakes function.

Updates

Lead Judging Commences

hrishibhat Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue
Assigned finding tags:

informational/invalid

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.