fix #2983 (segmentation fault of cppcheck)

This commit is contained in:
Robert Reif 2011-08-09 18:31:02 -04:00
parent 2b8b0c44b2
commit 10eb224ac7
2 changed files with 10 additions and 1 deletions

View File

@ -1773,7 +1773,7 @@ void Tokenizer::simplifyTypedef()
// don't add parenthesis around function names because it
// confuses other simplifications
bool needParen = true;
if (!inTemplate && function && tok2->next()->str() != "*")
if (!inTemplate && function && tok2->next() && tok2->next()->str() != "*")
needParen = false;
if (needParen)
{

View File

@ -262,6 +262,7 @@ private:
TEST_CASE(simplifyTypedef94); // ticket #1982
TEST_CASE(simplifyTypedef95); // ticket #2844
TEST_CASE(simplifyTypedef96); // ticket #2886
TEST_CASE(simplifyTypedef97); // ticket #2983 (segmentation fault)
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -5338,6 +5339,14 @@ private:
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
}
void simplifyTypedef97() // ticket #2983 (segmentation fault)
{
const char code[] = "typedef x y\n"
"(A); y\n";
sizeof_(code);
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedefFunction1()
{
{