From c986b6569765d7ec271507383691c3b19595e798 Mon Sep 17 00:00:00 2001 From: Alice Henshaw Date: Wed, 6 Nov 2024 16:17:31 +0000 Subject: [PATCH] initial implementation --- src/libraries/CalldataDecoder.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/CalldataDecoder.sol b/src/libraries/CalldataDecoder.sol index a14f3a34..585c1fc1 100644 --- a/src/libraries/CalldataDecoder.sol +++ b/src/libraries/CalldataDecoder.sol @@ -271,8 +271,9 @@ library CalldataDecoder { // shl(5, x) is equivalent to mul(32, x) let lengthPtr := add(_bytes.offset, and(calldataload(add(_bytes.offset, shl(5, _arg))), OFFSET_OR_LENGTH_MASK)) - // the number of bytes in the bytes string - length := and(calldataload(lengthPtr), OFFSET_OR_LENGTH_MASK) + // the number of bytes in the bytes string, rounded up to a multiple of 32 bytes + length := add(and(add(calldataload(lengthPtr), 0x1f), OFFSET_OR_LENGTH_MASK_AND_WORD_ALIGN), 0x20) + // the offset where the bytes string begins let offset := add(lengthPtr, 0x20) // assign the return parameters