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