From 91e7116de1250a1720a17ab38336c16bff97f847 Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Sat, 17 May 2014 19:14:29 +0200 Subject: [PATCH] Fix regression from first attempt fixing #5811 (9dce9bddcbbddb252653367f0e39a4c77108f5eb) --- lib/checknullpointer.cpp | 2 ++ test/testnullpointer.cpp | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 3e53906ac..efa7f2217 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -886,6 +886,8 @@ void CheckNullPointer::nullConstantDereference() if (Token::Match(tok2->previous(), ";|{|}|:|(")) break; } + if (tok2->previous()->str()=="(") + continue; if (Token::simpleMatch(tok2, "std :: cin")) nullPointerError(tok); if (tok2 && tok2->varId() != 0) { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 58d09cb95..892ed756f 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2141,6 +2141,15 @@ private: " return out.str();\n" "}n", true, "test.cpp", false); ASSERT_EQUALS("", errout.str()); + // avoid regression from first fix attempt for #5811... + check("void deserialize(const std::string &data) {\n" + "std::istringstream iss(data);\n" + "unsigned int len = 0;\n" + "if (!(iss >> len))\n" + " return;\n" + "}\n", true, "test.cpp", false); + ASSERT_EQUALS("", errout.str()); + } void functioncall() { // #3443 - function calls