diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index b6a64658a..a889661e8 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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) { diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 0fff9f6c9..3a4e2b734 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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() { {