20,000 USDC
View results
Submission Details
Severity: gas
Valid

Use `delete` to Clear Variables

Summary

Vulnerability Details

delete a assigns the initial value for the type to a. i.e.
for integers it is equivalent to a = 0, but it can also be used on arrays,
where it assigns a dynamic array of length zero or a static array of the same
length with all elements reset. For structs, it assigns a struct with all members reset.
Similarly, it can also be used to set an address to zero address.
It has no effect on whole mappings though (as the keys of mappings may be arbitrary
and are generally unknown). However, individual keys and what they map to can be deleted:
If a is a mapping, then delete a[x] will delete the value stored at x.

The delete key better conveys the intention and is also more idiomatic.
Consider replacing assignments of zero with delete statements.

There is 1 instance of this issue:

Impact

Tools Used

Recommendations

Replacing assignments of zero with delete statements.

Support

FAQs

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