From 7b6f03194df0a212ce35de387a6a758b9a3bf728 Mon Sep 17 00:00:00 2001 From: "mookim.eth" <97934198+mookim-eth@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:04:33 +0800 Subject: [PATCH] fix FreeENS.sol comments the first 32 bytes of a bytes variable is its length (instead of `address`) avoid using msize() to make optimizer happy. > SyntaxError: The msize instruction cannot be used when the Yul optimizer is activated because it can change its semantics. Either disable the Yul optimizer or do not use the instruction. --- src/FreeENS.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/FreeENS.sol b/src/FreeENS.sol index 7f9a929..33efa5b 100644 --- a/src/FreeENS.sol +++ b/src/FreeENS.sol @@ -33,15 +33,15 @@ contract FreeENS { } } - // insure abi encoding, not needed here but increase reusability for different return types - // note: abi.encode add a first 32 bytes word with the address of the original data + // ensure abi encoding, not needed here but increase reusability for different return types + // note: abi.encode add a first 32 bytes word with the length of the original data bytes memory _abiEncodedData = abi.encode(r); assembly { - // Return from the start of the data (discarding the original data address) - // up to the end of the memory used + // Return from the start of the data (skipping the data length field) + // mload(bytes) returns the length of the bytes variable let dataStart := add(_abiEncodedData, 0x20) - return(dataStart, sub(msize(), dataStart)) + return(dataStart, mload(_abiEncodedData)) } } }