Eric Sesterhenn: Fixed #1131 (descriptor leak false positive)

This commit is contained in:
Daniel Marjamäki 2009-12-22 19:13:46 +01:00
parent 5b87a51aa5
commit b4b63789fc
2 changed files with 4 additions and 1 deletions

View File

@ -847,7 +847,8 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
}
}
if (Token::Match(tok->previous(), "[;{})=] %var%"))
if (Token::Match(tok->previous(), "[;{})=] %var%") ||
Token::Match(tok->previous(), "|= %var%"))
{
AllocType dealloc = getDeallocationType(tok, varid);
if (dealloc != No)

View File

@ -493,6 +493,8 @@ private:
// open/close
ASSERT_EQUALS(";;alloc;if(var){dealloc;}", getcode("int f; f=open(); if(f>=0)close(f);", "f"));
ASSERT_EQUALS(";;alloc;ifv{;}", getcode("int f; f=open(); if(f!=-1 || x);", "f"));
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
}