From d3a837b340876a2fe09d9c741330dd676975c9bd Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 7 Apr 2022 13:38:22 +0200 Subject: [PATCH] Bugfix. --- libsolidity/codegen/ABIFunctions.cpp | 2 +- .../abiEncoderV2/calldata_nested_array_reencode.sol | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libsolidity/codegen/ABIFunctions.cpp b/libsolidity/codegen/ABIFunctions.cpp index 65f9e1723..d24dfc078 100644 --- a/libsolidity/codegen/ABIFunctions.cpp +++ b/libsolidity/codegen/ABIFunctions.cpp @@ -1454,7 +1454,7 @@ string ABIFunctions::calldataAccessFunction(Type const& _type) length := calldataload(value) value := add(value, 0x20) if gt(length, 0xffffffffffffffff) { () } - if sgt(base_ref, sub(calldatasize(), mul(length, ))) { () } + if sgt(value, sub(calldatasize(), mul(length, ))) { () } )") ("calldataStride", toCompactHexWithPrefix(arrayType->calldataStride())) // TODO add test diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol index d7ff1999b..042ad586e 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol @@ -14,10 +14,10 @@ contract C { // revertStrings: debug // ---- // h(uint256[][]): 0x20, 1, 0x20, 0 -> -// h(uint256[][]): 0x20, 1, 0x20, 1 -> -// h(uint256[][]): 0x20, 1, 0x20, 2 -> +// h(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// h(uint256[][]): 0x20, 1, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" // h(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" // f((uint256[])): 0x20, 0x20, 0 -> -// f((uint256[])): 0x20, 0x20, 1 -> -// f((uint256[])): 0x20, 0x20, 2 -> +// f((uint256[])): 0x20, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f((uint256[])): 0x20, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" // f((uint256[])): 0x20, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride"