File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,12 @@ FUZZ_TARGET(coins_view, .init = initialize_coins_view)
6969 if (e.what () == std::string{" Attempted to overwrite an unspent coin (when possible_overwrite is false)" }) {
7070 assert (!possible_overwrite);
7171 expected_code_path = true ;
72+ // AddCoin() decreases cachedCoinsUsage by the memory usage of the old coin at the beginning and
73+ // increases it by the value of the new coin at the end. If it throws in the process, the value
74+ // of cachedCoinsUsage would have been incorrectly decreased, leading to an underflow later on.
75+ // To avoid this, use Flush() to reset the value of cachedCoinsUsage in sync with the cacheCoins
76+ // mapping.
77+ (void )coins_view_cache.Flush ();
7278 }
7379 }
7480 assert (expected_code_path);
You can’t perform that action at this time.
0 commit comments