mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Bugfix in calldata unpacker.
The offset was not specified correctly if memory activity preceded the unpacker.
This commit is contained in:
@@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE(location_test)
|
||||
AssemblyItems items = compileContract(sourceCode);
|
||||
vector<SourceLocation> locations =
|
||||
vector<SourceLocation>(17, SourceLocation(2, 75, n)) +
|
||||
vector<SourceLocation>(26, SourceLocation(20, 72, n)) +
|
||||
vector<SourceLocation>(28, SourceLocation(20, 72, n)) +
|
||||
vector<SourceLocation>{SourceLocation(42, 51, n), SourceLocation(65, 67, n)} +
|
||||
vector<SourceLocation>(4, SourceLocation(58, 67, n)) +
|
||||
vector<SourceLocation>(3, SourceLocation(20, 72, n));
|
||||
|
||||
@@ -5354,6 +5354,25 @@ BOOST_AUTO_TEST_CASE(fixed_arrays_as_return_type)
|
||||
);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(calldata_offset)
|
||||
{
|
||||
// This tests a specific bug that was caused by not using the correct memory offset in the
|
||||
// calldata unpacker.
|
||||
char const* sourceCode = R"(
|
||||
contract CB
|
||||
{
|
||||
address[] _arr;
|
||||
string public last = "nd";
|
||||
function CB(address[] guardians)
|
||||
{
|
||||
_arr = guardians;
|
||||
}
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode, 0, "CB", encodeArgs(u256(0x20)));
|
||||
BOOST_CHECK(callContractFunction("last()", encodeArgs()) == encodeDyn(string("nd")));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user