The CharityRegistry::registerCharity() function in the contract does not check if a charity address has already been registered. This lack of validation can lead to redundant write operations, resulting in unnecessary gas consumption when attempting to register the same charity address multiple times.
The function sets a given address in the registeredCharities mapping to true without checking if it is already registered. If the same address is provided multiple times, the mapping will repeatedly write the same value (true). Although this does not alter the state from the user's perspective, it leads to unnecessary storage operations and gas costs.
Gas Inefficiency: Repeatedly registering the same address leads to unnecessary gas consumption. In the context of high-frequency or automated transactions, this can cause significant waste of gas over time.
No Direct State Impact: The mapping entry itself registeredCharities[charityAddress] remains set to true, so the logical state of the contract is not altered beyond increased gas usage.
Manual code review
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.