Fixed #1363 (false positive: memory leak)

This commit is contained in:
Daniel Marjamäki 2010-02-06 21:47:52 +01:00
parent ebf36c1150
commit 71117378ef
2 changed files with 2 additions and 0 deletions

View File

@ -1122,6 +1122,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
if (varid)
{
if (Token::Match(tok, "[)=] %varid% [+;)]", varid) ||
Token::Match(tok, "%var% + %varid%", varid) ||
Token::Match(tok, "%varid% +=|-=", varid) ||
Token::Match(tok, "+=|<< %varid% ;", varid) ||
Token::Match(tok, "= strcpy|strcat|memmove|memcpy ( %varid% ,", varid))

View File

@ -495,6 +495,7 @@ private:
ASSERT_EQUALS(";;use;", getcode("char *s; abc.a(s);", "s"));
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"));
// return..
ASSERT_EQUALS(";;return;", getcode("char *s; return;", "s"));