fix #2637 (segmentation fault of cppcheck ( {} const const ))

This commit is contained in:
Robert Reif 2011-03-15 22:33:14 -04:00
parent ba0b3e6451
commit 47531dd99c
2 changed files with 13 additions and 1 deletions

View File

@ -1467,6 +1467,9 @@ void Scope::getVariableList()
continue;
tok = checkVariable(tok, varaccess);
if (!tok)
break;
}
}
@ -1515,7 +1518,7 @@ const Token *Scope::checkVariable(const Token *tok, AccessControl varaccess)
bool isArray = false;
if (isVariableDeclaration(tok, vartok, typetok, isArray))
if (tok && isVariableDeclaration(tok, vartok, typetok, isArray))
{
isClass = (!typetok->isStandardType() && vartok->previous()->str() != "*");
tok = vartok->next();

View File

@ -196,6 +196,7 @@ private:
TEST_CASE(symboldatabase13); // ticket #2577
TEST_CASE(symboldatabase14); // ticket #2589
TEST_CASE(symboldatabase15); // ticket #2591
TEST_CASE(symboldatabase16); // ticket #2637
}
// Check the operator Equal
@ -5791,6 +5792,14 @@ private:
ASSERT_EQUALS("", errout.str());
}
void symboldatabase16()
{
// ticket #2637 - segmentation fault
checkConst("{} const const\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestClass)