Fixed #1778 (false negative: nullpointer dereference (std::string pointer))
This commit is contained in:
parent
068317bed1
commit
a3367874d9
|
@ -2685,7 +2685,10 @@ private:
|
||||||
vartok = vartok->tokAt(3);
|
vartok = vartok->tokAt(3);
|
||||||
while (vartok && (vartok->str() == "*" || vartok->isName()))
|
while (vartok && (vartok->str() == "*" || vartok->isName()))
|
||||||
vartok = vartok->next();
|
vartok = vartok->next();
|
||||||
if (Token::Match(vartok, "> * %var% ;|="))
|
}
|
||||||
|
if (vartok
|
||||||
|
&& (vartok->str() == ">" || vartok->isName())
|
||||||
|
&& Token::Match(vartok->next(), "* %var% ;|="))
|
||||||
{
|
{
|
||||||
vartok = vartok->tokAt(2);
|
vartok = vartok->tokAt(2);
|
||||||
checks.push_back(new CheckNullpointer(owner, vartok->varId(), vartok->str()));
|
checks.push_back(new CheckNullpointer(owner, vartok->varId(), vartok->str()));
|
||||||
|
@ -2694,7 +2697,6 @@ private:
|
||||||
return vartok->next();
|
return vartok->next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Token::simpleMatch(&tok, "try {"))
|
if (Token::simpleMatch(&tok, "try {"))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1134,7 +1134,7 @@ private:
|
||||||
" std::string * x = 0;\n"
|
" std::string * x = 0;\n"
|
||||||
" *x = \"test\";\n"
|
" *x = \"test\";\n"
|
||||||
"}\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[])
|
void checkUninitVar(const char code[])
|
||||||
|
|
Loading…
Reference in New Issue