Fixed #2261 (False positive: memory leak)
This commit is contained in:
parent
6761765a70
commit
0081800a20
|
@ -1518,6 +1518,16 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
}
|
||||
}
|
||||
|
||||
for (Token *tok1 = rethead; tok1; tok1 = tok1->next())
|
||||
{
|
||||
if (Token::simpleMatch(tok1, "callfunc alloc ;"))
|
||||
{
|
||||
tok1->deleteThis();
|
||||
tok1->insertToken("use");
|
||||
tok1->insertToken(";");
|
||||
}
|
||||
}
|
||||
|
||||
return rethead;
|
||||
}
|
||||
|
||||
|
|
|
@ -535,6 +535,7 @@ private:
|
|||
ASSERT_EQUALS(";;;use;", getcode("char *p; const char *q; q = p;", "p"));
|
||||
ASSERT_EQUALS(";;use;;", getcode("char *s; x = {1,s};", "s"));
|
||||
ASSERT_EQUALS(";{};;alloc;;use;", getcode("struct Foo { }; Foo *p; p = malloc(10); const Foo *q; q = p;", "p"));
|
||||
ASSERT_EQUALS(";;alloc;use;", getcode("Fred *fred; p.setFred(fred = new Fred);", "fred"));
|
||||
|
||||
// non-use..
|
||||
ASSERT_EQUALS(";;", getcode("char *s; s = s + 1;", "s"));
|
||||
|
|
Loading…
Reference in New Issue