Fixed #2849 (False positive: memory leak (using question mark operator))
This commit is contained in:
parent
77859b9a0f
commit
6375e1d3dc
|
@ -1498,6 +1498,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
}
|
||||
|
||||
if (Token::Match(tok, "[)=] %varid% [+;)]", varid) ||
|
||||
Token::Match(tok, "= %varid% ? %varid% :", varid) ||
|
||||
Token::Match(tok, "%var% + %varid%", varid) ||
|
||||
Token::Match(tok, "%varid% +=|-=", varid) ||
|
||||
Token::Match(tok, "+=|<< %varid% ;", varid) ||
|
||||
|
|
|
@ -484,6 +484,7 @@ private:
|
|||
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"));
|
||||
ASSERT_EQUALS(";;use;", getcode("char *s; *s2 = s ? s : p;", "s"));
|
||||
|
||||
// non-use..
|
||||
ASSERT_EQUALS(";;", getcode("char *s; s = s + 1;", "s"));
|
||||
|
|
Loading…
Reference in New Issue