diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 5523f7bad..d2ff16c91 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2685,14 +2685,16 @@ private: vartok = vartok->tokAt(3); while (vartok && (vartok->str() == "*" || vartok->isName())) vartok = vartok->next(); - if (Token::Match(vartok, "> * %var% ;|=")) - { - vartok = vartok->tokAt(2); - checks.push_back(new CheckNullpointer(owner, vartok->varId(), vartok->str())); - if (Token::simpleMatch(vartok->next(), "= 0 ;")) - setnull(checks, vartok->varId()); - return vartok->next(); - } + } + if (vartok + && (vartok->str() == ">" || vartok->isName()) + && Token::Match(vartok->next(), "* %var% ;|=")) + { + vartok = vartok->tokAt(2); + checks.push_back(new CheckNullpointer(owner, vartok->varId(), vartok->str())); + if (Token::simpleMatch(vartok->next(), "= 0 ;")) + setnull(checks, vartok->varId()); + return vartok->next(); } } diff --git a/test/testother.cpp b/test/testother.cpp index c3f5a4039..29adb8cbc 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1134,7 +1134,7 @@ private: " std::string * x = 0;\n" " *x = \"test\";\n" "}\n"); - TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: x\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error) Possible null pointer dereference: x\n", errout.str()); } void checkUninitVar(const char code[])