fix #3006 (segmentation fault of cppcheck ( x < () < ))

This commit is contained in:
Robert Reif 2011-08-15 07:19:49 -04:00
parent 4168d79b09
commit a6c5eff1be
2 changed files with 7 additions and 1 deletions

View File

@ -2420,7 +2420,7 @@ bool Tokenizer::tokenize(std::istream &code,
;
else if (level == 0)
inclevel = true;
else if (tok2->next()->isStandardType())
else if (tok2->next() && tok2->next()->isStandardType())
inclevel = true;
else if (Token::simpleMatch(tok2, "< typename"))
inclevel = true;

View File

@ -52,6 +52,7 @@ private:
TEST_CASE(tokenize16); // #2612 - segfault for "<><<"
TEST_CASE(tokenize17); // #2759
TEST_CASE(tokenize18); // tokenize "(X&&Y)" into "( X && Y )" instead of "( X & & Y )"
TEST_CASE(tokenize19); // #3006 (segmentation fault)
// don't freak out when the syntax is wrong
TEST_CASE(wrong_syntax);
@ -570,6 +571,11 @@ private:
ASSERT_EQUALS("( X && Y )", tokenizeAndStringify("(X&&Y)"));
}
void tokenize19() // #3006 (segmentation fault)
{
tokenizeAndStringify("x < () <");
}
void wrong_syntax()
{
{