Pieces Protocol

First Flight #32
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Redundant Zero Address Check in transferErcTokens Function

Summary

The transferErcTokens function in the contract contains a duplicate check for the zero address of the to parameter, which is unnecessary and wastes gas.

Vulnerability Details

In the transferErcTokens function, there are two identical checks for whether the to address is zero:

if(to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}
// ... some code ...
if(to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}

The second check is redundant as the first check already ensures that the to address is not zero.

Impact

The duplicate check results in:

  • Unnecessary gas consumption

  • Code bloat

  • Reduced code maintainability

Tools Used

  • Manual code review

Recommendations

Remove the second zero address check

Updates

Lead Judging Commences

fishy Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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