Properly cleanup after copying dynamic-array to storage for packed types

This commit is contained in:
Harikrishnan Mulackal
2020-10-06 16:06:02 +02:00
committed by hrkrshnn
parent 87e1934bee
commit 1bdbc10110
5 changed files with 81 additions and 3 deletions
+5 -1
View File
@@ -290,7 +290,10 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
// stack: target_ref target_data_end source_data_pos target_data_pos_updated source_data_end
_context << Instruction::POP << Instruction::SWAP1 << Instruction::POP;
// stack: target_ref target_data_end target_data_pos_updated
utils.clearStorageLoop(targetBaseType);
if (targetBaseType->storageBytes() < 32)
utils.clearStorageLoop(TypeProvider::uint256());
else
utils.clearStorageLoop(targetBaseType);
_context << Instruction::POP;
}
);
@@ -922,6 +925,7 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
void ArrayUtils::clearStorageLoop(TypePointer _type) const
{
solAssert(_type->storageBytes() >= 32, "");
m_context.callLowLevelFunction(
"$clearStorageLoop_" + _type->identifier(),
2,