Merge pull request #8004 from ethereum/fix-7960

abiv2 proto converter: Resize dynamic storage arrays via push
This commit is contained in:
Leonardo 2020-01-07 15:48:20 +01:00 committed by GitHub
commit 8385256bdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -810,13 +810,16 @@ pair<string, string> AssignCheckVisitor::visit(ArrayType const& _type)
length = getDynArrayLengthFromFuzz(_type.length(), counter());
lengthStr = to_string(length);
if (m_stateVar)
resizeBuffer = assignAndCheckStringPair(
m_varName + ".length",
m_paramName + ".length",
lengthStr,
lengthStr,
DataType::VALUE
);
{
// Dynamic storage arrays are resized via the empty push() operation
resizeBuffer.first = Whiskers(R"(<indentation>for (uint i = 0; i < <length>; i++) <arrayRef>.push();)")
("indentation", indentation())
("length", lengthStr)
("arrayRef", m_varName)
.render() + "\n";
// Add a dynamic check on the resized length
resizeBuffer.second = checkString(m_paramName + ".length", lengthStr, DataType::VALUE);
}
else
{
// Resizing memory arrays via the new operator