mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix #4716: Crash when array index value is too large
This commit is contained in:
@@ -2211,12 +2211,13 @@ bool TypeChecker::visit(IndexAccess const& _access)
|
||||
else
|
||||
{
|
||||
expectType(*index, IntegerType(256));
|
||||
if (auto numberType = dynamic_cast<RationalNumberType const*>(type(*index).get()))
|
||||
{
|
||||
if (!numberType->isFractional()) // error is reported above
|
||||
if (!m_errorReporter.hasErrors())
|
||||
if (auto numberType = dynamic_cast<RationalNumberType const*>(type(*index).get()))
|
||||
{
|
||||
solAssert(!numberType->isFractional(), "");
|
||||
if (!actualType.isDynamicallySized() && actualType.length() <= numberType->literalValue(nullptr))
|
||||
m_errorReporter.typeError(_access.location(), "Out of bounds array access.");
|
||||
}
|
||||
}
|
||||
}
|
||||
resultType = actualType.baseType();
|
||||
isLValue = actualType.location() != DataLocation::CallData;
|
||||
|
||||
Reference in New Issue
Block a user