Fixed #518 (False positive for leaks when function from err()-family used)
This commit is contained in:
parent
7479b943cc
commit
ab4a7fdef2
|
@ -943,11 +943,25 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
addtoken(tok->strAt(0));
|
||||
|
||||
// exit..
|
||||
if (Token::Match(tok->previous(), "[{};] exit ( %any% ) ;"))
|
||||
if (Token::Match(tok->previous(), "[{};] exit|_exit|_Exit ( %any% ) ;"))
|
||||
{
|
||||
addtoken("exit");
|
||||
tok = tok->tokAt(3);
|
||||
}
|
||||
else if (Token::simpleMatch(tok, "abort ( ) ;"))
|
||||
{
|
||||
addtoken("exit");
|
||||
tok = tok->tokAt(2);
|
||||
}
|
||||
else if (Token::Match(tok, "err|verr|errx|verrx ("))
|
||||
{
|
||||
addtoken("exit");
|
||||
while (tok->next() && tok->next()->str() != ";")
|
||||
{
|
||||
tok = tok->next();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Assignment..
|
||||
if (varid)
|
||||
|
|
|
@ -384,6 +384,9 @@ private:
|
|||
|
||||
// exit..
|
||||
ASSERT_EQUALS(";;exit;", getcode("char *s; exit(0);", "s"));
|
||||
ASSERT_EQUALS(";;exit;", getcode("char *s; _exit(0);", "s"));
|
||||
ASSERT_EQUALS(";;exit;", getcode("char *s; abort();", "s"));
|
||||
ASSERT_EQUALS(";;exit;", getcode("char *s; err(0);", "s"));
|
||||
ASSERT_EQUALS(";;if{exit;}", getcode("char *s; if (a) { exit(0); }", "s"));
|
||||
|
||||
// open/close
|
||||
|
|
Loading…
Reference in New Issue