Skip to content

Commit 216f997

Browse files
authored
Update ABIDecoderTests.cpp
1 parent 52b96b5 commit 216f997

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/libsolidity/ABIDecoderTests.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,24 @@ BOOST_AUTO_TEST_CASE(complex_struct)
426426
)
427427
}
428428

429+
BOOST_AUTO_TEST_CASE(invalid_tuple_offset)
430+
{
431+
std::string sourceCode = R"(
432+
contract C {
433+
function f((uint a, uint b) calldata x) external pure returns (uint) {
434+
return x.a + x.b;
435+
}
436+
}
437+
)";
438+
BOTH_ENCODERS(
439+
compileAndRun(sourceCode);
440+
// Creating an invalid call with tuple offset pointing outside the calldata
441+
bytes calldata = encodeArgs(0x20, 0xffff) + bytes(62, 0); // 0xffff is an invalid offset
442+
// This should revert because the tuple offset is invalid
443+
ABI_CHECK(callContractFunctionNoEncoding("f((uint256,uint256))", calldata), encodeArgs());
444+
)
445+
}
446+
429447
BOOST_AUTO_TEST_SUITE_END()
430448

431449
} // end namespaces

0 commit comments

Comments
 (0)