Permalink
Browse files

Fixed ticket #3543 (segmentation fault of cppcheck).

  • Loading branch information...
1 parent aaa6070 commit bc034095f134fcaefddbbfd8bcbc18d1d795ba1f Edoardo Prezioso committed Jan 31, 2012
Showing with 13 additions and 0 deletions.
  1. +2 −0 lib/symboldatabase.cpp
  2. +11 −0 test/testsymboldatabase.cpp
View
@@ -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;
@@ -153,6 +153,7 @@ class TestSymbolDatabase: public TestFixture {
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 @@ class TestSymbolDatabase: public TestFixture {
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)

0 comments on commit bc03409

Please sign in to comment.