diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index c8e970a2c..17f6a9ab1 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -324,6 +324,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti // find start of function '{' while (end && end->str() != "{") end = end->next(); + if (!end) + continue; // save start of function function.start = end; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 9a54291d3..31df5a199 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -153,6 +153,7 @@ private: TEST_CASE(symboldatabase24); // ticket #3508 (constructor, destructor) TEST_CASE(symboldatabase25); // ticket #3561 (throw C++) TEST_CASE(symboldatabase26); // ticket #3561 (throw C) + TEST_CASE(symboldatabase27); // ticket #3543 (segmentation fault) } void test_isVariableDeclarationCanHandleNull() { @@ -1118,6 +1119,16 @@ private: ASSERT(db && db->getVariableListSize() == 2); // index 0 + 1 variable } + // #ticket #3543 (segmentation fault) + void symboldatabase27() { + check("class C : public B1\n" + "{\n" + " B1()\n" + " {} C(int) : B1() class\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + }; REGISTER_TEST(TestSymbolDatabase)