Fixed #2251 (False positive: Possible null pointer reference)
This commit is contained in:
parent
cdb685c83c
commit
065af5c444
|
@ -115,7 +115,7 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown)
|
||||||
if (Token::Match(tok->tokAt(-3), "!!sizeof [;{}=+-/(,] * %var%"))
|
if (Token::Match(tok->tokAt(-3), "!!sizeof [;{}=+-/(,] * %var%"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!Token::simpleMatch(tok->tokAt(-2), "& (") && tok->strAt(-1) != "&&" && Token::Match(tok->next(), ". %var%"))
|
if (!Token::simpleMatch(tok->tokAt(-2), "& (") && tok->strAt(-1) != "&" && tok->strAt(-1) != "&&" && Token::Match(tok->next(), ". %var%"))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (Token::Match(tok->previous(), "[;{}=+-/(,] %var% ["))
|
if (Token::Match(tok->previous(), "[;{}=+-/(,] %var% ["))
|
||||||
|
|
|
@ -609,6 +609,14 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// ticket #2251: taking the address of member
|
||||||
|
check("void f() {\n"
|
||||||
|
" Fred *fred = 0;\n"
|
||||||
|
" int x = &fred->x;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer7()
|
void nullpointer7()
|
||||||
|
|
Loading…
Reference in New Issue