aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen
diff options
context:
space:
mode:
authorErik Kundt <bitshift@posteo.org>2018-05-29 17:25:13 +0800
committerErik Kundt <bitshift@posteo.org>2018-05-30 23:46:43 +0800
commitfea0d116f7d95e9a39f0c80c5156cb3656b03ce0 (patch)
tree15e1bb09d9b341676e3c6a13bf0110a4ff3b15b9 /libsolidity/codegen
parent98d52beba3f989b3a5eeaba2d257de8de5df60a7 (diff)
downloaddexon-solidity-fea0d116f7d95e9a39f0c80c5156cb3656b03ce0.tar.gz
dexon-solidity-fea0d116f7d95e9a39f0c80c5156cb3656b03ce0.tar.zst
dexon-solidity-fea0d116f7d95e9a39f0c80c5156cb3656b03ce0.zip
Fixes assembly bug and adds tests to cover it.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r--libsolidity/codegen/ArrayUtils.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp
index 6bb9a961..14c887c3 100644
--- a/libsolidity/codegen/ArrayUtils.cpp
+++ b/libsolidity/codegen/ArrayUtils.cpp
@@ -848,9 +848,9 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
}
case 1 {
// long byte array
+ mstore(0, ref)
let length := div(slot_value, 2)
let slot := keccak256(0, 0x20)
- mstore(0, ref)
switch length
case 32
{
@@ -861,14 +861,13 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
}
default
{
- let slot_offset := div(sub(length, 1), 32)
- let length_offset := and(sub(length, 1), 0x1f)
- slot := add(slot, slot_offset)
+ let offset_inside_slot := and(sub(length, 1), 0x1f)
+ slot := add(slot, div(sub(length, 1), 32))
let data := sload(slot)
// Zero-out the suffix of the byte array by masking it.
// ((1<<(8 * (32 - offset))) - 1)
- let mask := sub(exp(0x100, sub(32, length_offset)), 1)
+ let mask := sub(exp(0x100, sub(32, offset_inside_slot)), 1)
data := and(not(mask), data)
sstore(slot, data)