fix #2886 (crash of cppcheck ( typedef struct x { } ))
This commit is contained in:
parent
8ec1dfacbf
commit
b143b283e9
|
@ -898,7 +898,7 @@ static Token *splitDefinitionFromTypedef(Token *tok)
|
|||
tok1->insertToken(";");
|
||||
tok1 = tok1->next();
|
||||
|
||||
if (tok1->next()->str() == ";" && tok1 && tok1->previous()->str() == "}")
|
||||
if (tok1->next() && tok1->next()->str() == ";" && tok1 && tok1->previous()->str() == "}")
|
||||
{
|
||||
tok->deleteThis();
|
||||
tok1->deleteThis();
|
||||
|
|
|
@ -260,6 +260,7 @@ private:
|
|||
TEST_CASE(simplifyTypedef93); // ticket #2738
|
||||
TEST_CASE(simplifyTypedef94); // ticket #1982
|
||||
TEST_CASE(simplifyTypedef95); // ticket #2844
|
||||
TEST_CASE(simplifyTypedef96); // ticket #2886
|
||||
|
||||
TEST_CASE(simplifyTypedefFunction1);
|
||||
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
|
||||
|
@ -5374,6 +5375,13 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedef96() // ticket #2886 (segmentation fault)
|
||||
{
|
||||
const char code[] = "typedef struct x { }\n";
|
||||
sizeof_(code);
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
}
|
||||
|
||||
void simplifyTypedefFunction1()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue