Do not perform cleanup on unsigned integers when loading from calldata.

This commit is contained in:
chriseth
2018-11-14 20:52:30 +00:00
committed by Alex Beregszaszi
parent 1e4765fba7
commit 727e3f24bc
3 changed files with 10 additions and 2 deletions
+8 -1
View File
@@ -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;
}