Fixed #2411 (possible null pointer dereference (aborting via function pointer not detected))

This commit is contained in:
Daniel Marjamäki 2011-01-05 21:48:26 +01:00
parent 033e759c39
commit c74b2e3cbf
2 changed files with 10 additions and 1 deletions

View File

@ -553,7 +553,8 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
// calling unknown function (abort/init)..
if (Token::simpleMatch(tok2, ") ;") &&
Token::Match(tok2->link()->tokAt(-2), "[;{}] %var% ("))
(Token::Match(tok2->link()->tokAt(-2), "[;{}] %var% (") ||
Token::Match(tok2->link()->tokAt(-5), "[;{}] ( * %var% ) (")))
{
break;
}

View File

@ -754,6 +754,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
check("void foo(char *p) {\n"
" if (!p) {\n"
" (*bail)();\n"
" }\n"
" *p = 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
check("void foo(char *p) {\n"
" if (!p) {\n"
" throw x;\n"