fix #2865 (segmentation fault of cppcheck ( char a[1] ))

This commit is contained in:
Robert Reif 2011-06-27 07:31:10 -04:00
parent 1713eeb532
commit 272eb445fb
2 changed files with 10 additions and 1 deletions

View File

@ -1305,7 +1305,7 @@ bool SymbolDatabase::arrayDimensions(std::vector<Dimension> &dimensions, const T
const Token *dim = tok; const Token *dim = tok;
while (dim->str() == "[" && dim->next() && dim->next()->str() != "]") while (dim && dim->next() && dim->str() == "[" && dim->next()->str() != "]")
{ {
Dimension dimension; Dimension dimension;
dimension.num = 0; dimension.num = 0;

View File

@ -120,6 +120,7 @@ private:
TEST_CASE(symboldatabase15); // ticket #2591 TEST_CASE(symboldatabase15); // ticket #2591
TEST_CASE(symboldatabase16); // ticket #2637 TEST_CASE(symboldatabase16); // ticket #2637
TEST_CASE(symboldatabase17); // ticket #2657 TEST_CASE(symboldatabase17); // ticket #2657
TEST_CASE(symboldatabase18); // ticket #2865
} }
void test_isVariableDeclarationCanHandleNull() void test_isVariableDeclarationCanHandleNull()
@ -869,6 +870,14 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void symboldatabase18()
{
// ticket #2865 - segmentation fault
check("char a[1]\n");
ASSERT_EQUALS("", errout.str());
}
}; };
REGISTER_TEST(TestSymbolDatabase) REGISTER_TEST(TestSymbolDatabase)