diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 76731cd82..8e4c4f083 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -194,7 +194,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown, const Set return false; // read/write member variable - if (firstOperand && parent->str() == "." && (!parent->astParent() || parent->astParent()->str() != "&")) { + if (firstOperand && parent->originalName() == "->" && (!parent->astParent() || parent->astParent()->str() != "&")) { if (!parent->astParent() || parent->astParent()->str() != "(" || parent->astParent() == tok->previous()) return true; unknown = true; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index a3d15f308..2a7fc2c63 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2596,6 +2596,15 @@ private: " var->f();\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #9439 + check("char* g();\n" + "char* f() {\n" + " std::unique_ptr x(g());\n" + " if( x ) {}\n" + " return x.release();\n" + "}\n", true); + ASSERT_EQUALS("", errout.str()); } void functioncall() { // #3443 - function calls diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b074400f6..b43268818 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -4503,7 +4503,7 @@ private: "\n" "int main() {\n" " Foo* foo;\n" - " foo.b\n" + " foo->b\n" "}\n"); ASSERT_EQUALS("[test.cpp:7]: (error) Uninitialized variable: foo\n", errout.str()); }