Pieces Protocol

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

Duplicate Check for to == address(0) in tranferErcTokens()

Summary

The function checks if to == address(0) twice, which is redundant and can be optimized. The second check occurs after the state has already been updated, potentially leading to inconsistencies if the check fails later.

Vulnerability Details

The code contains two checks for to == address(0)

Impact

  • Redundancy: The code performs the same check twice, which is unnecessary and can make the code harder to read and maintain.

  • Gas Inefficiency: Duplicate checks consume more gas than needed.

  • State Inconsistency Risk: Checking to == address(0) after updating balances (which happens before the second check) could lead to inconsistencies if the check fails after balances are modified.

Tools Used

Manual code review.

Recommendations

Remove the second check for to == address(0) since it is redundant. Perform the check at the beginning of the function before any state is modified. This will improve efficiency and reduce the risk of inconsistencies.

Updates

Lead Judging Commences

fishy Lead Judge 8 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.