Merge pull request #11930 from ethereum/calldataStructInlineAssembly

Fix inline assembly assignments to calldata structs and statically-sized calldata arrays.
This commit is contained in:
chriseth
2021-09-14 16:16:48 +02:00
committed by GitHub
10 changed files with 111 additions and 25 deletions
+22 -9
View File
@@ -860,15 +860,28 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly)
}
else if (variable->type()->dataStoredIn(DataLocation::CallData))
{
auto const* arrayType = dynamic_cast<ArrayType const*>(variable->type());
solAssert(
arrayType && arrayType->isDynamicallySized() && arrayType->dataStoredIn(DataLocation::CallData),
""
);
solAssert(suffix == "offset" || suffix == "length", "");
solAssert(variable->type()->sizeOnStack() == 2, "");
if (suffix == "length")
stackDiff--;
if (auto const* arrayType = dynamic_cast<ArrayType const*>(variable->type()))
{
if (arrayType->isDynamicallySized())
{
solAssert(suffix == "offset" || suffix == "length", "");
solAssert(variable->type()->sizeOnStack() == 2, "");
if (suffix == "length")
stackDiff--;
}
else
{
solAssert(variable->type()->sizeOnStack() == 1, "");
solAssert(suffix.empty(), "");
}
}
else
{
auto const* structType = dynamic_cast<StructType const*>(variable->type());
solAssert(structType, "");
solAssert(variable->type()->sizeOnStack() == 1, "");
solAssert(suffix.empty(), "");
}
}
else
solAssert(suffix.empty(), "");