Fixed #2849 (False positive: memory leak (using question mark operator))

This commit is contained in:
Daniel Marjamäki 2011-06-30 17:31:22 +02:00
parent 77859b9a0f
commit 6375e1d3dc
2 changed files with 2 additions and 0 deletions

View File

@ -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) ||

View File

@ -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"));