fix #2630 (segmentation fault of cppcheck ( typedef ... )
This commit is contained in:
parent
c457179ce6
commit
7a7257f200
|
@ -1151,6 +1151,13 @@ void Tokenizer::simplifyTypedef()
|
|||
while (Token::Match(tok->tokAt(offset), "*|&|const"))
|
||||
pointers.push_back(tok->tokAt(offset++)->str());
|
||||
|
||||
// check for invalid input
|
||||
if (!tok->tokAt(offset))
|
||||
{
|
||||
syntaxError(tok);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Token::Match(tok->tokAt(offset), "%type%"))
|
||||
{
|
||||
// found the type name
|
||||
|
|
|
@ -4973,8 +4973,16 @@ private:
|
|||
|
||||
void simplifyTypedef84() // ticket #2630 (segmentation fault)
|
||||
{
|
||||
const char code[] = "typedef y x () x\n";
|
||||
checkSimplifyTypedef(code);
|
||||
const char code1[] = "typedef y x () x\n";
|
||||
checkSimplifyTypedef(code1);
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
|
||||
const char code2[] = "typedef struct template <>\n";
|
||||
checkSimplifyTypedef(code2);
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
|
||||
const char code3[] = "typedef ::<>\n";
|
||||
checkSimplifyTypedef(code3);
|
||||
ASSERT_EQUALS("[test.cpp:1]: (error) syntax error\n", errout.str());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue