CheckNullPointer::isPointerDeRef: Tweaks to reduce false warnings when inconclusive is used.
This commit is contained in:
parent
497c54a1a7
commit
ffb5d107be
|
@ -83,7 +83,7 @@ static std::string bufferOverrunMessage(std::string varnames)
|
|||
std::string errmsg("Buffer access out-of-bounds");
|
||||
if (!varnames.empty())
|
||||
errmsg += ": " + varnames;
|
||||
|
||||
|
||||
return errmsg;
|
||||
}
|
||||
|
||||
|
|
|
@ -254,6 +254,15 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown)
|
|||
if (Token::Match(tok->previous(), "delete %var%") || Token::Match(tok->tokAt(-3), "delete [ ] %var%"))
|
||||
return false;
|
||||
|
||||
// OK to check if pointer is null
|
||||
// OK to take address of pointer
|
||||
if (Token::Match(tok->previous(), "!|& %var% )|,|&&|%oror%"))
|
||||
return false;
|
||||
|
||||
// OK to pass pointer to function
|
||||
if (Token::Match(tok->previous(), ", %var% [,)]"))
|
||||
return false;
|
||||
|
||||
// unknown if it's a dereference
|
||||
unknown = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue