From 8cd38abf558fd8fb4fbd6d36d1d4ba40d79b2c37 Mon Sep 17 00:00:00 2001 From: t11s Date: Thu, 8 Feb 2024 16:48:10 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Comments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/TransientReentrancyGuard.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/TransientReentrancyGuard.sol b/src/utils/TransientReentrancyGuard.sol index 4ea5e3c3..8db47700 100644 --- a/src/utils/TransientReentrancyGuard.sol +++ b/src/utils/TransientReentrancyGuard.sol @@ -16,6 +16,8 @@ abstract contract TransientReentrancyGuard { assembly { noReentrancy := iszero(tload(REENTRANCY_GUARD_SLOT)) + // Any non-zero value would work, but + // ADDRESS is cheap and certainly not 0. tstore(REENTRANCY_GUARD_SLOT, address()) } @@ -25,6 +27,9 @@ abstract contract TransientReentrancyGuard { /// @solidity memory-safe-assembly assembly { + // Need to set back to zero, as transient + // storage is only cleared at the end of the + // tx, not the end of the outermost call frame. tstore(REENTRANCY_GUARD_SLOT, 0) } }