From d098ed60317510fd592c3ddf4ab063d3ee06480c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 3 Sep 2011 19:43:27 +0200 Subject: [PATCH] Fixed #3065 (False positive: possible null pointer dereference: vi) --- lib/checknullpointer.cpp | 2 +- test/testnullpointer.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 63f333c55..e3682658a 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -763,7 +763,7 @@ 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% ) ("))) { // noreturn function? diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 0c4afa9c1..9829abf73 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -1062,6 +1062,14 @@ private: "}\n"); 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" " if (!p) {\n" " switch (x) { }\n"