fix #2630 (segmentation fault of cppcheck ( typedef y x () x ))

This commit is contained in:
Robert Reif 2011-03-06 18:59:56 -05:00
parent a77993db75
commit d678e4424c
2 changed files with 16 additions and 11 deletions

View File

@ -1185,19 +1185,16 @@ void Tokenizer::simplifyTypedef()
tok = deleteInvalidTypedef(typeDef);
continue;
}
else if (!Token::Match(tok->tokAt(offset)->link(), ") ;|,"))
{
syntaxError(tok);
return;
}
function = true;
if (tok->tokAt(offset)->link()->next())
{
argStart = tok->tokAt(offset);
argEnd = tok->tokAt(offset)->link();
tok = argEnd->next();
}
else
{
// internal error
continue;
}
argStart = tok->tokAt(offset);
argEnd = tok->tokAt(offset)->link();
tok = argEnd->next();
}
// unhandled typedef, skip it and continue

View File

@ -245,6 +245,7 @@ private:
TEST_CASE(simplifyTypedef81); // ticket #2603
TEST_CASE(simplifyTypedef82); // ticket #2403
TEST_CASE(simplifyTypedef83); // ticket #2620
TEST_CASE(simplifyTypedef84); // ticket #2630
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4975,6 +4976,13 @@ private:
ASSERT_EQUALS(expected, sizeof_(code));
}
void simplifyTypedef84() // ticket #2630 (segmentation fault)
{
const char code[] = "typedef y x () x\n";
checkSimplifyTypedef(code);
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
}
void simplifyTypedefFunction1()
{
{