improved overflow check in memorySize for ArrayType

This commit is contained in:
LianaHus 2015-09-24 10:51:06 +02:00
parent 52f7e35843
commit 99ec6702df

View File

@ -859,9 +859,9 @@ u256 ArrayType::memorySize() const
{ {
solAssert(!isDynamicallySized(), ""); solAssert(!isDynamicallySized(), "");
solAssert(m_location == DataLocation::Memory, ""); solAssert(m_location == DataLocation::Memory, "");
u256 size = m_length * m_baseType->memoryHeadSize(); bigint size = bigint(m_length) * m_baseType->memoryHeadSize();
solAssert(size <= numeric_limits<unsigned>::max(), "Array size does not fit unsigned."); solAssert(size <= numeric_limits<unsigned>::max(), "Array size does not fit u256.");
return size; return u256(size);
} }
TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer) const TypePointer ArrayType::copyForLocation(DataLocation _location, bool _isPointer) const