Fixed #1801 (Segmentation fault while scanning Qt's qcups.cpp)

This commit is contained in:
Robert Reif 2010-06-17 06:59:01 +02:00 committed by Daniel Marjamäki
parent ad4681223b
commit f116e74f6e
2 changed files with 14 additions and 1 deletions

View File

@ -1008,7 +1008,8 @@ void Tokenizer::simplifyTypedef()
}
// function returning pointer to function
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( * %type% ("))
else if (tok->tokAt(offset) && Token::Match(tok->tokAt(offset), "( * %type% (") &&
Token::Match(tok->tokAt(offset + 3)->link(), ") ) ("))
{
functionRetFuncPtr = true;

View File

@ -203,6 +203,7 @@ private:
TEST_CASE(simplifyTypedef50);
TEST_CASE(simplifyTypedef51);
TEST_CASE(simplifyTypedef52); // ticket #1782
TEST_CASE(simplifyTypedef53); // ticket #1801
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -4179,6 +4180,17 @@ private:
}
}
void simplifyTypedef53() // ticket #1801
{
{
const char code[] = "typedef int ( * int ( * ) ( ) ) ( ) ;";
// this is invalid C so just make sure it doesn't crash
checkSimplifyTypedef(code);
ASSERT_EQUALS("", errout.str());
}
}
void simplifyTypedefFunction1()
{
{