Fixed #3023 (False positive: no possible null pointer dereference here: 'WARN_ON(!abc || abc->x == 0);')
This commit is contained in:
parent
dd09b24208
commit
27b29e5b8e
|
@ -590,6 +590,14 @@ void CheckNullPointer::nullPointerByDeRefAndChec()
|
|||
{
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok1->previous(), "&&|%oror%"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok1->tokAt(-2), "&&|%oror% !"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (CheckNullPointer::isPointerDeRef(tok1, unknown))
|
||||
{
|
||||
nullPointerError(tok1, varname, tok->linenr());
|
||||
|
|
|
@ -584,6 +584,18 @@ private:
|
|||
" ;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #3023 - checked deref
|
||||
check("void f(struct ABC *abc) {\n"
|
||||
" WARN_ON(!abc || abc->x == 0);\n"
|
||||
" if (!abc) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
check("void f(struct ABC *abc) {\n"
|
||||
" WARN_ON(!abc || abc->x == 7);\n"
|
||||
" if (!abc) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void nullpointer5()
|
||||
|
|
Loading…
Reference in New Issue