diff options
author | chriseth <c@ethdev.com> | 2016-07-28 23:19:17 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2016-07-28 23:24:18 +0800 |
commit | 58cc6cbb379015d57b8f6dec3b4a5c207ccb6b0b (patch) | |
tree | 5f838b1813be0088e459c205af14cd04392a138b /libsolidity/codegen/ExpressionCompiler.cpp | |
parent | ea4fd3c6e25517180a773a6e4b51de0505e781ec (diff) | |
download | dexon-solidity-58cc6cbb379015d57b8f6dec3b4a5c207ccb6b0b.tar.gz dexon-solidity-58cc6cbb379015d57b8f6dec3b4a5c207ccb6b0b.tar.zst dexon-solidity-58cc6cbb379015d57b8f6dec3b4a5c207ccb6b0b.zip |
Bugfix: Allocate empty array.
Diffstat (limited to 'libsolidity/codegen/ExpressionCompiler.cpp')
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index b973a117..80009a90 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -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: |