fix #2831 (crash of cppcheck ( z<y<x> ))

This commit is contained in:
Robert Reif 2011-06-12 08:38:15 -04:00
parent d1b260699a
commit 729ee72a5a
2 changed files with 9 additions and 0 deletions

View File

@ -3633,6 +3633,8 @@ void Tokenizer::setVarId()
while (tok2->str() != ">")
tok2 = tok2->next();
tok2 = tok2->next();
if (!tok2) // syntax error
return;
if (tok2->str() == ",")
tok2 = tok2->next();
if (level == 1 && tok2->str() == ">")

View File

@ -174,6 +174,7 @@ private:
TEST_CASE(varid28); // ticket #2630
TEST_CASE(varid29); // ticket #1974
TEST_CASE(varid30); // ticket #2614
TEST_CASE(varid31); // ticket #2831 (segmentation fault)
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2910,6 +2911,12 @@ private:
ASSERT_EQUALS(expected3, tokenizeDebugListing(code3));
}
void varid31() // ticket #2831 (segmentation fault)
{
const std::string code("z<y<x>");
ASSERT_EQUALS("", errout.str());
}
void varidFunctionCall1()
{
const std::string code("void f() {\n"