Merge pull request #6132 from ethereum/ossfuzz-nullref-typechecker

TypeChecker: Check if type exists before dereferencing it
This commit is contained in:
chriseth
2019-02-28 16:38:54 +01:00
committed by GitHub
3 changed files with 26 additions and 7 deletions
+9
View File
@@ -632,6 +632,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly)
bool requiresStorage = ref->second.isSlot || ref->second.isOffset;
if (auto var = dynamic_cast<VariableDeclaration const*>(declaration))
{
solAssert(var->type(), "Expected variable type!");
if (var->isConstant())
{
m_errorReporter.typeError(_identifier.location, "Constant variables not supported by inline assembly.");
@@ -1012,6 +1013,14 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
}
}
if (valueTypes.size() != variables.size())
{
solAssert(m_errorReporter.hasErrors(), "Should have errors!");
for (auto const& var: variables)
if (var && !var->annotation().type)
BOOST_THROW_EXCEPTION(FatalError());
}
if (autoTypeDeductionNeeded)
{
if (!typeCanBeExpressed(variables))