Fixed #3065 (False positive: possible null pointer dereference: vi)

This commit is contained in:
Daniel Marjamäki 2011-09-03 19:43:27 +02:00
parent c7886ca1c4
commit d098ed6031
2 changed files with 9 additions and 1 deletions

View File

@ -763,7 +763,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
// calling unknown function (abort/init).. // calling unknown function (abort/init)..
if (Token::simpleMatch(tok2, ") ;") && 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% ) ("))) Token::Match(tok2->link()->tokAt(-5), "[;{}] ( * %var% ) (")))
{ {
// noreturn function? // noreturn function?

View File

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