aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-08 06:52:13 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-11-15 04:52:30 +0800
commit727e3f24bc57b9470b7972fe882d60117625afe5 (patch)
tree199d350f723cd845a9fffd7f09811f187e7afe9d /libsolidity
parent1e4765fba7a061d8440b5bdb57ba074874c7e171 (diff)
downloaddexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar.gz
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar.bz2
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar.lz
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar.xz
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.tar.zst
dexon-solidity-727e3f24bc57b9470b7972fe882d60117625afe5.zip
Do not perform cleanup on unsigned integers when loading from calldata.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/CompilerUtils.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp
index 90eb74fe..a0d11017 100644
--- a/libsolidity/codegen/CompilerUtils.cpp
+++ b/libsolidity/codegen/CompilerUtils.cpp
@@ -1236,6 +1236,7 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
}
solAssert(numBytes <= 32, "Static memory load of more than 32 bytes requested.");
m_context << (_fromCalldata ? Instruction::CALLDATALOAD : Instruction::MLOAD);
+ bool cleanupNeeded = true;
if (isExternalFunctionType)
splitExternalFunctionType(true);
else if (numBytes != 32)
@@ -1245,10 +1246,16 @@ unsigned CompilerUtils::loadFromMemoryHelper(Type const& _type, bool _fromCallda
int shiftFactor = (32 - numBytes) * 8;
rightShiftNumberOnStack(shiftFactor);
if (leftAligned)
+ {
leftShiftNumberOnStack(shiftFactor);
+ cleanupNeeded = false;
+ }
+ else if (IntegerType const* intType = dynamic_cast<IntegerType const*>(&_type))
+ if (!intType->isSigned())
+ cleanupNeeded = false;
}
if (_fromCalldata)
- convertType(_type, _type, true, false, true);
+ convertType(_type, _type, cleanupNeeded, false, true);
return numBytes;
}