From b628b9b69242112321165542a4e9b39198edd941 Mon Sep 17 00:00:00 2001 From: kaden Date: Mon, 10 Jun 2024 14:59:12 -0700 Subject: [PATCH] Update mapping-within-struct.md --- vulnerabilities/mapping-within-struct.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vulnerabilities/mapping-within-struct.md b/vulnerabilities/mapping-within-struct.md index a427c49..74487de 100644 --- a/vulnerabilities/mapping-within-struct.md +++ b/vulnerabilities/mapping-within-struct.md @@ -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. @@ -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 \ No newline at end of file +- https://docs.soliditylang.org/en/latest/types.html#delete