fix #2835 (crash of cppcheck ( ><,f<i, ))
This commit is contained in:
parent
729ee72a5a
commit
e584b08066
|
@ -3605,6 +3605,9 @@ void Tokenizer::setVarId()
|
|||
|
||||
do // Look for start of templates or template arguments
|
||||
{
|
||||
if (!tok2) // syntax error
|
||||
return;
|
||||
|
||||
again = false;
|
||||
|
||||
if (tok2 && tok2->str() == "const")
|
||||
|
@ -3622,8 +3625,14 @@ void Tokenizer::setVarId()
|
|||
else if (Token::Match(tok2, "%type% *|&| ,"))
|
||||
{
|
||||
tok2 = tok2->tokAt(2);
|
||||
if (!tok2) // syntax error
|
||||
return;
|
||||
if (tok2->str() == ",")
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
if (!tok2) // syntax error
|
||||
return;
|
||||
}
|
||||
again = true;
|
||||
}
|
||||
else if (level > 1 && (Token::Match(tok2, "%type% *|&| >") ||
|
||||
|
@ -3636,7 +3645,11 @@ void Tokenizer::setVarId()
|
|||
if (!tok2) // syntax error
|
||||
return;
|
||||
if (tok2->str() == ",")
|
||||
{
|
||||
tok2 = tok2->next();
|
||||
if (!tok2) // syntax error
|
||||
return;
|
||||
}
|
||||
if (level == 1 && tok2->str() == ">")
|
||||
break;
|
||||
again = true;
|
||||
|
|
|
@ -175,6 +175,7 @@ private:
|
|||
TEST_CASE(varid29); // ticket #1974
|
||||
TEST_CASE(varid30); // ticket #2614
|
||||
TEST_CASE(varid31); // ticket #2831 (segmentation fault)
|
||||
TEST_CASE(varid32); // ticket #2835 (segmentation fault)
|
||||
TEST_CASE(varidFunctionCall1);
|
||||
TEST_CASE(varidFunctionCall2);
|
||||
TEST_CASE(varidFunctionCall3);
|
||||
|
@ -2917,6 +2918,12 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varid32() // ticket #2835 (segmentation fault)
|
||||
{
|
||||
const std::string code("><,f<i,");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void varidFunctionCall1()
|
||||
{
|
||||
const std::string code("void f() {\n"
|
||||
|
|
Loading…
Reference in New Issue