Fixed FP: Null pointer dereference
This commit is contained in:
parent
f8f3f0d384
commit
a70b0cd0f3
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue