From 190a0040b7c81e1ab4e27ec9c92e2c97ba22755e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 2 Sep 2010 21:08:58 +0200 Subject: [PATCH] Null pointer: Fixed false positive --- lib/checkother.cpp | 2 +- test/testother.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 3be0a0025..1ec8df6e8 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2431,7 +2431,7 @@ void CheckOther::nullPointerLinkedList() } --indentlevel4; } - else if (tok4->str() == "break") + else if (tok4->str() == "break" || tok4->str() == "return") break; } } diff --git a/test/testother.cpp b/test/testother.cpp index 55936796a..b0dfaf1c6 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -925,6 +925,18 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkNullPointer("void f()\n" + "{\n" + " for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())\n" + " {\n" + " while (tok && tok->str() != \"{\")\n" + " tok = tok->next();\n" + " if (!tok)\n" + " return;\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // dynamic_cast.. checkNullPointer("void foo(ABC *abc)\n" "{\n"