Fixed FP: Null pointer dereference

This commit is contained in:
Lucas Manuel Rodriguez 2013-08-24 16:50:19 -03:00
parent f8f3f0d384
commit a70b0cd0f3
2 changed files with 7 additions and 1 deletions

View File

@ -1204,7 +1204,7 @@ void CheckNullPointer::nullConstantDereference()
}
const Variable *ovar = 0;
if (Token::Match(tok, "0 ==|!= %var%"))
if (Token::Match(tok, "0 ==|!= %var% !!."))
ovar = tok->tokAt(2)->variable();
else if (Token::Match(tok, "%var% ==|!= 0"))
ovar = tok->variable();

View File

@ -1958,6 +1958,12 @@ private:
" std::string s = 0 == x ? \"a\" : \"b\";\n"
"}", true);
ASSERT_EQUALS("", errout.str());
check("void f() {\n"
" const std::string s = g();\n"
" ASSERT_MESSAGE(\"Error on s\", 0 == s.compare(\"Some text\"));\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void nullpointerStdStream() {