Fixed #1707 (false positive: Memory leak)
This commit is contained in:
parent
c465d824b7
commit
5692e7a6f6
|
@ -960,6 +960,28 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
dep = true;
|
||||
break;
|
||||
}
|
||||
if (innerParlevel > 0 && Token::Match(tok2, "%var% ("))
|
||||
{
|
||||
bool use = false;
|
||||
for (const Token *tok3 = tok2->tokAt(2); tok3; tok3 = tok3->next())
|
||||
{
|
||||
if (tok3->str() == "(")
|
||||
tok3 = tok3->link();
|
||||
else if (tok3->str() == ")")
|
||||
break;
|
||||
else if (Token::Match(tok3->previous(), "(|, %varid% ,|)", varid))
|
||||
{
|
||||
use = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (use)
|
||||
{
|
||||
addtoken("use");
|
||||
addtoken(";");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "if ( ! %varid% &&", varid))
|
||||
|
|
|
@ -494,6 +494,7 @@ private:
|
|||
ASSERT_EQUALS(";;use;", getcode("char *s; s2 = s;", "s"));
|
||||
ASSERT_EQUALS(";;use;", getcode("char *s; s2 = s + 10;", "s"));
|
||||
ASSERT_EQUALS(";;use;", getcode("char *s; s2 = x + s;", "s"));
|
||||
ASSERT_EQUALS(";;use;if{;}", getcode("char *s; if (foo(s)) ;", "s"));
|
||||
|
||||
// return..
|
||||
ASSERT_EQUALS(";;return;", getcode("char *s; return;", "s"));
|
||||
|
|
Loading…
Reference in New Issue