Fixed #1800 (false positive: memory leak when ptr used as map key)

This commit is contained in:
Daniel Marjamäki 2010-06-21 18:43:28 +02:00
parent bdd28b47aa
commit d22da6088c
2 changed files with 3 additions and 1 deletions

View File

@ -1282,7 +1282,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
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))
Token::Match(tok, "= strcpy|strcat|memmove|memcpy ( %varid% ,", varid) ||
Token::Match(tok, "[;{}] %var% [ %varid% ]", varid))
{
addtoken("use");
}

View File

@ -499,6 +499,7 @@ private:
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"));
ASSERT_EQUALS(";;use;", getcode("char *s; map1[s] = 0;", "s"));
// return..
ASSERT_EQUALS(";;return;", getcode("char *s; return;", "s"));