mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix crash for too large struct array indicies
This commit is contained in:
parent
d3820aa833
commit
9f431339ef
@ -4,6 +4,7 @@ Bugfixes:
|
|||||||
* Code generator: Defensively pad allocation of creationCode and runtimeCode to multiples of 32 bytes.
|
* Code generator: Defensively pad allocation of creationCode and runtimeCode to multiples of 32 bytes.
|
||||||
* Parser: Disallow empty import statements.
|
* Parser: Disallow empty import statements.
|
||||||
* Type Checker: Dissallow mappings with data locations other than 'storage'
|
* Type Checker: Dissallow mappings with data locations other than 'storage'
|
||||||
|
* Type Checker: Fix internal error when a struct array index does not fit into a uint256.
|
||||||
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
|
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
|
||||||
|
|
||||||
|
|
||||||
|
@ -2205,15 +2205,22 @@ bool TypeChecker::visit(IndexAccess const& _access)
|
|||||||
resultType = make_shared<TypeType>(make_shared<ArrayType>(DataLocation::Memory, typeType.actualType()));
|
resultType = make_shared<TypeType>(make_shared<ArrayType>(DataLocation::Memory, typeType.actualType()));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
expectType(*index, IntegerType::uint256());
|
u256 length = 1;
|
||||||
if (auto length = dynamic_cast<RationalNumberType const*>(type(*index).get()))
|
if (expectType(*index, IntegerType::uint256()))
|
||||||
resultType = make_shared<TypeType>(make_shared<ArrayType>(
|
{
|
||||||
DataLocation::Memory,
|
if (auto indexValue = dynamic_cast<RationalNumberType const*>(type(*index).get()))
|
||||||
typeType.actualType(),
|
length = indexValue->literalValue(nullptr);
|
||||||
length->literalValue(nullptr)
|
else
|
||||||
));
|
m_errorReporter.fatalTypeError(index->location(), "Integer constant expected.");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_errorReporter.fatalTypeError(index->location(), "Integer constant expected.");
|
solAssert(m_errorReporter.hasErrors(), "Expected errors as expectType returned false");
|
||||||
|
|
||||||
|
resultType = make_shared<TypeType>(make_shared<ArrayType>(
|
||||||
|
DataLocation::Memory,
|
||||||
|
typeType.actualType(),
|
||||||
|
length
|
||||||
|
));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
contract test {
|
||||||
|
struct s { uint a; uint b;}
|
||||||
|
function f() pure public returns (byte) {
|
||||||
|
s[75555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555];
|
||||||
|
s[7];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// TypeError: (101-241): Type int_const 7555...(132 digits omitted)...5555 is not implicitly convertible to expected type uint256.
|
Loading…
Reference in New Issue
Block a user