Fixed ticket #3543 (segmentation fault of cppcheck).

This commit is contained in:
Edoardo Prezioso 2012-01-31 19:34:55 +01:00
parent aaa6070fc9
commit bc034095f1
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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)