fix #2601 (segmentation fault of cppcheck)
This commit is contained in:
parent
ba6c2ca310
commit
703448171a
|
@ -5980,6 +5980,9 @@ void Tokenizer::simplifyIfNotNull()
|
||||||
{
|
{
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
||||||
|
if (!tok)
|
||||||
|
break;
|
||||||
|
|
||||||
if (Token::simpleMatch(tok, "0 != (") ||
|
if (Token::simpleMatch(tok, "0 != (") ||
|
||||||
Token::Match(tok, "0 != %var%"))
|
Token::Match(tok, "0 != %var%"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -326,6 +326,8 @@ private:
|
||||||
TEST_CASE(simplifyFunctionReturn);
|
TEST_CASE(simplifyFunctionReturn);
|
||||||
|
|
||||||
TEST_CASE(removeUnnecessaryQualification);
|
TEST_CASE(removeUnnecessaryQualification);
|
||||||
|
|
||||||
|
TEST_CASE(simplifyIfNotNull);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tok(const char code[], bool simplify = true)
|
std::string tok(const char code[], bool simplify = true)
|
||||||
|
@ -6516,6 +6518,13 @@ private:
|
||||||
ASSERT_EQUALS(expected, tok(code, false));
|
ASSERT_EQUALS(expected, tok(code, false));
|
||||||
ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:1]: (portability) Extra qualification 'Fred::' unnecessary and considered an error by many compilers.\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyIfNotNull() // ticket # 2601 segmentation fault
|
||||||
|
{
|
||||||
|
const char code[] = "|| #if #define <=";
|
||||||
|
tok(code, false);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestSimplifyTokens)
|
REGISTER_TEST(TestSimplifyTokens)
|
||||||
|
|
Loading…
Reference in New Issue