Pieces Protocol

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

Duplicate Check for to == Address(0) in transferErcTokens Function

Summary

The transferErcTokens function in the TokenDivider.sol contract contains a redundant check for the to address being zero. The check if(to == address(0)) is performed twice, line 190 and line 200 which is unnecessary and can be optimized

if(to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}
if(to == address(0)) {
revert TokenDivider__CantTransferToAddressZero();
}

Vulnerability Details

Impact

While this redundancy does not introduce a security vulnerability, it does lead to inefficient code and can affect readability. Redundant checks can also increase the gas cost of executing the function, albeit minimally.

POC:

Deploy the TokenDivider contract.
Call the transferErcTokens function with any valid parameters.
Observe that the check for to == address(0) is performed twice.

Tools Used

manual review

Recommendations

Remove the redundant check for to == address(0) to improve code efficiency and readability. Ensure that the check is performed only once.

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.