mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10043 from ethereum/emptyArrayCopy
Fix empty array copy bug.
This commit is contained in:
@@ -125,6 +125,15 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
|
||||
// special case for short byte arrays: Store them together with their length.
|
||||
if (_targetType.isByteArray())
|
||||
{
|
||||
// stack: target_ref target_data_end source_length target_data_pos source_ref
|
||||
_context << Instruction::DUP3;
|
||||
evmasm::AssemblyItem nonEmptyByteArray = _context.appendConditionalJump();
|
||||
// Empty source, just zero out the main slot.
|
||||
_context << u256(0) << Instruction::DUP6 << Instruction::SSTORE;
|
||||
_context.appendJumpTo(copyLoopEndWithoutByteOffset);
|
||||
|
||||
_context << nonEmptyByteArray;
|
||||
// Non-empty source.
|
||||
// stack: target_ref target_data_end source_length target_data_pos source_ref
|
||||
_context << Instruction::DUP3 << u256(31) << Instruction::LT;
|
||||
evmasm::AssemblyItem longByteArray = _context.appendConditionalJump();
|
||||
|
||||
Reference in New Issue
Block a user