Skip to content

Commit

Permalink
Update mapping-within-struct.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kadenzipfel authored Jun 10, 2024
1 parent da5ff81 commit b628b9b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vulnerabilities/mapping-within-struct.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deleting a Mapping Within a Struct

It is a common assumption that deleting ``struct`` will delete all of it's data entirely but there is an exception. Deleting structs with dynamic data types does not delete the data stored inside them.
It is a common assumption that deleting a ``struct`` will delete all of it's data entirely but there is an exception. Deleting structs with dynamic data types does not delete the data stored inside them.

For example: If a ``mapping`` (or dynamic array) is inside a struct, and the struct is deleted, the mapping will not be deleted. This is because mappings are implemented as hash tables and the EVM does not keep track of which keys have been used in the mapping. As a result, EVM doesn't know how to reset a mapping and the remaining data can be used to compromise the contract.

Expand All @@ -21,4 +21,4 @@ For example: If a ``mapping`` (or dynamic array) is inside a struct, and the str


## Sources
- https://docs.soliditylang.org/en/latest/types.html#delete
- https://docs.soliditylang.org/en/latest/types.html#delete

0 comments on commit b628b9b

Please sign in to comment.