diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index d58ec03ec..c639bf27d 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -541,7 +541,8 @@ Token *Tokenizer::processFunc(Token *tok2, bool inOperator) const return nullptr; if (tok2->str() == "(" && - tok2->link()->next()->str() == "(") { + tok2->link()->next() && + tok2->link()->next()->str() == "(") { tok2 = tok2->link(); if (tok2->next()->str() == "(") diff --git a/test/testgarbage.cpp b/test/testgarbage.cpp index 39b6f4dc6..5a1dc4fdf 100644 --- a/test/testgarbage.cpp +++ b/test/testgarbage.cpp @@ -117,6 +117,7 @@ private: TEST_CASE(garbageCode76); TEST_CASE(garbageCode77); TEST_CASE(garbageCode78); + TEST_CASE(garbageCode79); TEST_CASE(garbageValueFlow); TEST_CASE(garbageSymbolDatabase); @@ -650,6 +651,10 @@ private: checkCode("( ) { [ ] } ( ) { } const_array_of_int ( ) { } typedef int A [ ] [ ] ; A a = { { } { } }"); } + void garbageCode79() { // #6757 + ASSERT_THROW(checkCode("{ } { } typedef void ( func_type ) ( ) ; func_type & ( )"), InternalError); + } + void garbageValueFlow() { // #6089 const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"