mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Bugfix: Allocate empty array.
This commit is contained in:
@@ -104,6 +104,7 @@ public:
|
||||
);
|
||||
|
||||
/// Zero-initialises (the data part of) an already allocated memory array.
|
||||
/// Length has to be nonzero!
|
||||
/// Stack pre: <length> <memptr>
|
||||
/// Stack post: <updated_memptr>
|
||||
void zeroInitialiseMemoryArray(ArrayType const& _type);
|
||||
|
||||
@@ -792,15 +792,18 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
||||
utils().storeFreeMemoryPointer();
|
||||
// Stack: memptr requested_length
|
||||
|
||||
// Check if length is zero
|
||||
m_context << Instruction::DUP1 << Instruction::ISZERO;
|
||||
auto skipInit = m_context.appendConditionalJump();
|
||||
|
||||
// We only have to initialise if the base type is a not a value type.
|
||||
if (dynamic_cast<ReferenceType const*>(arrayType.baseType().get()))
|
||||
{
|
||||
m_context << Instruction::DUP2 << u256(32) << Instruction::ADD;
|
||||
utils().zeroInitialiseMemoryArray(arrayType);
|
||||
m_context << Instruction::POP;
|
||||
}
|
||||
else
|
||||
m_context << Instruction::POP;
|
||||
m_context << skipInit;
|
||||
m_context << Instruction::POP;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user