Fix #4716: Crash when array index value is too large

This commit is contained in:
bakaoh
2018-09-05 10:54:38 +07:00
parent 410d288dfc
commit a7ffff6a29
3 changed files with 14 additions and 4 deletions
+5 -4
View File
@@ -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;