From 6796afc2f8b441803a2c03f28271a1421935e536 Mon Sep 17 00:00:00 2001 From: chriseth Date: Sun, 29 Nov 2015 00:59:01 +0100 Subject: Bugfix for constructor unpacking with fixed-size arrays. --- libsolidity/codegen/Compiler.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'libsolidity/codegen/Compiler.cpp') diff --git a/libsolidity/codegen/Compiler.cpp b/libsolidity/codegen/Compiler.cpp index f1d95980..18803b71 100644 --- a/libsolidity/codegen/Compiler.cpp +++ b/libsolidity/codegen/Compiler.cpp @@ -305,11 +305,19 @@ void Compiler::appendCalldataUnpacker(TypePointers const& _typeParameters, bool // @todo If base type is an array or struct, it is still calldata-style encoded, so // we would have to convert it like below. solAssert(arrayType.location() == DataLocation::Memory, ""); - // compute data pointer - m_context << eth::Instruction::DUP1 << eth::Instruction::MLOAD; - m_context << eth::Instruction::DUP3 << eth::Instruction::ADD; - m_context << eth::Instruction::SWAP2 << eth::Instruction::SWAP1; - m_context << u256(0x20) << eth::Instruction::ADD; + if (arrayType.isDynamicallySized()) + { + // compute data pointer + m_context << eth::Instruction::DUP1 << eth::Instruction::MLOAD; + m_context << eth::Instruction::DUP3 << eth::Instruction::ADD; + m_context << eth::Instruction::SWAP2 << eth::Instruction::SWAP1; + m_context << u256(0x20) << eth::Instruction::ADD; + } + else + { + m_context << eth::Instruction::DUP1; + m_context << u256(arrayType.calldataEncodedSize(true)) << eth::Instruction::ADD; + } } else { -- cgit