fix #2875 (segmentation fault of cppcheck ( 0; (a) < (a) ))

This commit is contained in:
Robert Reif 2011-06-28 18:47:18 -04:00
parent 866c836020
commit 70a32fc245
2 changed files with 8 additions and 1 deletions

View File

@ -3682,7 +3682,7 @@ void Tokenizer::setVarId()
if (tok2 && tok2->str() == "(")
{
tok2 = tok2->link()->next();
if (tok2->str() == "(")
if (tok2 && tok2->str() == "(")
tok2 = tok2->link()->next();
again = true;
}

View File

@ -177,6 +177,7 @@ private:
TEST_CASE(varid30); // ticket #2614
TEST_CASE(varid31); // ticket #2831 (segmentation fault)
TEST_CASE(varid32); // ticket #2835 (segmentation fault)
TEST_CASE(varid33); // ticket #2875 (segmentation fault)
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2954,6 +2955,12 @@ private:
ASSERT_EQUALS("", errout.str());
}
void varid33() // ticket #2875 (segmentation fault)
{
const std::string code("0; (a) < (a)");
ASSERT_EQUALS("", errout.str());
}
void varidFunctionCall1()
{
const std::string code("void f() {\n"