Fixed #3238 (Crash in obsolete functions check.)

This commit is contained in:
Erik Lax 2011-10-22 12:36:45 +02:00 committed by Daniel Marjamäki
parent ccf087d2ea
commit 2b54f00c87
2 changed files with 7 additions and 1 deletions

View File

@ -47,7 +47,7 @@ void CheckObsoleteFunctions::obsoleteFunctions()
if (tok->isName() && tok->varId()==0 && (tok->next() && tok->next()->str() == "(") &&
(!Token::Match(tok->previous(), ".|::|:|,") || Token::simpleMatch(tok->previous()->previous(), "std :: gets"))) {
// c function declaration?
if ((tok->next()->link()->next() && tok->next()->link()->next()->str() == ";") && (tok->previous()->str() == "*" || tok->previous()->isName())) {
if ((tok->next()->link()->next() && tok->next()->link()->next()->str() == ";") && (tok->previous() && (tok->previous()->str() == "*" || tok->previous()->isName()))) {
continue;
}

View File

@ -64,6 +64,8 @@ private:
// function with body
TEST_CASE(test_function_with_body);
// null pointer dereference in obsoleteFunctions
TEST_CASE(ticket3238);
}
void check(const char code[]) {
@ -288,6 +290,10 @@ private:
ASSERT_EQUALS("", errout.str());
}
void ticket3238() {
check("__FBSDID(\"...\");\n");
ASSERT_EQUALS("", errout.str());
}
};