Fixed #1235 (CheckMemoryLeakInFunction: Wrong handling of 'fcloseall')

This commit is contained in:
Daniel Marjamäki 2010-01-07 21:36:51 +01:00
parent 83545ab11f
commit 686137415f
2 changed files with 9 additions and 1 deletions

View File

@ -853,7 +853,11 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
Token::Match(tok->previous(), "|= %var%"))
{
AllocType dealloc = getDeallocationType(tok, varid);
if (dealloc != No)
if (dealloc != No && tok->str() == "fcloseall" && alloctype != dealloc)
dealloc = No;
else if (dealloc != No)
{
addtoken("dealloc");

View File

@ -498,6 +498,10 @@ private:
ASSERT_EQUALS(";;alloc;ifv{;}", getcode("int f; f=open(); if(f!=-1 || x);", "f"));
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
// fcloseall..
ASSERT_EQUALS(";;alloc;;", getcode("char *s; s = malloc(10); fcloseall();", "s"));
ASSERT_EQUALS(";;alloc;dealloc;", getcode("FILE *f; f = fopen(a,b); fcloseall();", "f"));
}