diff options
author | Dmitry K <winsvega@mail.ru> | 2016-08-02 16:11:09 +0800 |
---|---|---|
committer | Dmitry K <winsvega@mail.ru> | 2016-08-02 16:11:09 +0800 |
commit | a10b6f92f97bf2eacc80534f6640e08f0b26e95d (patch) | |
tree | ffb7d72d52ae7a8d30194186bc15886c10118c5a /libsolidity/codegen | |
parent | d1c744450965644df17fcc73006dd7495e75c477 (diff) | |
parent | 85a61fe886c2d99d397bf30cc01d971558130287 (diff) | |
download | dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.gz dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.bz2 dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.lz dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.xz dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.tar.zst dexon-solidity-a10b6f92f97bf2eacc80534f6640e08f0b26e95d.zip |
Merge branch 'develop' of https://github.com/ethereum/solidity into develop
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/CompilerUtils.h | 1 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index 55254013..da74dc90 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -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); 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: |