mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixes assembly bug and adds tests to cover it.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user