fix #2657 (segmentation fault of cppcheck ( gcc-testsuite: return f(){} ))

This commit is contained in:
Robert Reif 2011-03-17 20:10:56 -04:00
parent 7b63da4964
commit 1de35c168d
2 changed files with 10 additions and 1 deletions

View File

@ -1455,7 +1455,7 @@ void Scope::getVariableList()
// skip return and delete
else if (Token::Match(tok, "return|delete"))
{
while (tok->next()->str() != ";")
while (tok->next() && tok->next()->str() != ";")
tok = tok->next();
continue;
}

View File

@ -197,6 +197,7 @@ private:
TEST_CASE(symboldatabase14); // ticket #2589
TEST_CASE(symboldatabase15); // ticket #2591
TEST_CASE(symboldatabase16); // ticket #2637
TEST_CASE(symboldatabase17); // ticket #2657
}
// Check the operator Equal
@ -5805,6 +5806,14 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase17()
{
// ticket #2657 - segmentation fault
checkConst("return f(){}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)