fix #2630 (segmentation fault of cppcheck ( typedef y x () x ))
This commit is contained in:
parent
a77993db75
commit
d678e4424c
|
@ -1185,20 +1185,17 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
// unhandled typedef, skip it and continue
|
||||
else
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue