Fixed #2192 (false positive: resource leak)

This commit is contained in:
Daniel Marjamäki 2010-11-11 17:40:20 +01:00
parent 07f4067fa8
commit 0328d26fcb
2 changed files with 4 additions and 1 deletions

View File

@ -1317,7 +1317,9 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
Token::simpleMatch(tok2->next(), "["))
{
}
else if (f.empty() || !test_white_list(f.top()->str()))
else if (f.empty() ||
!test_white_list(f.top()->str()) ||
getDeallocationType(f.top(),varid))
{
use = true;
}

View File

@ -485,6 +485,7 @@ private:
ASSERT_EQUALS(";;dealloc;", getcode("void *p; foo(fclose(p));", "p"));
ASSERT_EQUALS(";;dealloc;", getcode("void *p; foo(close(p));", "p"));
ASSERT_EQUALS(";;;;", getcode("FILE *f1; FILE *f2; fclose(f1);", "f2"));
ASSERT_EQUALS(";;returnuse;", getcode("FILE *f; return fclose(f) == EOF ? 1 : 2;", "f"));
// if..
ASSERT_EQUALS(";;if{}", getcode("char *s; if (a) { }", "s"));