aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-11-17 01:32:21 +0800
committerchriseth <c@ethdev.com>2015-11-17 01:32:21 +0800
commit0c900f9b8afe4094ca52030f55fcf5e84980cc12 (patch)
tree263bbba4f24ed18f304b7f2aae57396e665de3d8 /libsolidity/codegen
parentc881d103b26ff80ddfe6bfcea186bdca46a27d30 (diff)
downloaddexon-solidity-0c900f9b8afe4094ca52030f55fcf5e84980cc12.tar.gz
dexon-solidity-0c900f9b8afe4094ca52030f55fcf5e84980cc12.tar.zst
dexon-solidity-0c900f9b8afe4094ca52030f55fcf5e84980cc12.zip
Fix memory overwrite problem for arrays.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/LValue.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp
index 574d42f8..864f28d0 100644
--- a/libsolidity/codegen/LValue.cpp
+++ b/libsolidity/codegen/LValue.cpp
@@ -103,10 +103,20 @@ void MemoryItem::storeValue(Type const& _sourceType, SourceLocation const&, bool
if (!_move)
{
utils.moveToStackTop(m_dataType->sizeOnStack());
- utils.copyToStackTop(2, m_dataType->sizeOnStack());
+ utils.copyToStackTop(1 + m_dataType->sizeOnStack(), m_dataType->sizeOnStack());
+ }
+ if (!m_padded)
+ {
+ solAssert(m_dataType->calldataEncodedSize(false) == 1, "Invalid non-padded type.");
+ if (m_dataType->category() == Type::Category::FixedBytes)
+ m_context << u256(0) << eth::Instruction::BYTE;
+ m_context << eth::Instruction::SWAP1 << eth::Instruction::MSTORE8;
+ }
+ else
+ {
+ utils.storeInMemoryDynamic(*m_dataType, m_padded);
+ m_context << eth::Instruction::POP;
}
- utils.storeInMemoryDynamic(*m_dataType, m_padded);
- m_context << eth::Instruction::POP;
}
else
{