Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

No Zero Balance Check in withdrawFees

Summary

The withdrawFees() function doesn't check for a zero balance before attempting to transfer funds.

Vulnerability Details

Location: src/TrickOrTreat.sol:withdrawFees()

Impact

This can lead to unnecessary gas consumption and failed transactions when the contract balance is zero.

Tools Used

Forge

Recommendations

Add a check to ensure the contract balance is greater than zero before initiating the transfer:

function withdrawFees() public onlyOwner {
uint256 balance = address(this).balance;
require(balance > 0, "No balance to withdraw");
payable(owner()).transfer(balance);
emit FeeWithdrawn(owner(), balance);
}
Updates

Appeal created

bube Lead Judge 9 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.