Fixed #2607 (segmentation fault of cppcheck ( struct C {} {} x))

This commit is contained in:
Daniel Marjamäki 2011-03-09 21:00:28 +01:00
parent be33f6b945
commit bea3875386
2 changed files with 10 additions and 2 deletions

View File

@ -1975,6 +1975,9 @@ bool CheckBufferOverrun::ArrayInfo::declare(const Token *tok, const Tokenizer &t
_element_size = 0; _element_size = 0;
_varname.clear(); _varname.clear();
if (!tok)
return false;
if (!tok->isName() || tok->str() == "return") if (!tok->isName() || tok->str() == "return")
return false; return false;

View File

@ -198,7 +198,8 @@ private:
TEST_CASE(terminateStrncpy3); TEST_CASE(terminateStrncpy3);
TEST_CASE(recursive_long_time); TEST_CASE(recursive_long_time);
TEST_CASE(crash); // Ticket #1587 - crash TEST_CASE(crash1); // Ticket #1587 - crash
TEST_CASE(crash2); // Ticket #2607 - crash
TEST_CASE(executionPaths1); TEST_CASE(executionPaths1);
TEST_CASE(executionPaths2); TEST_CASE(executionPaths2);
@ -2709,7 +2710,7 @@ private:
// Ticket #1587 - crash // Ticket #1587 - crash
void crash() void crash1()
{ {
check("struct struct A\n" check("struct struct A\n"
"{\n" "{\n"
@ -2724,6 +2725,10 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void crash2()
{
check("struct C {} {} x");
}
void epcheck(const char code[]) void epcheck(const char code[])