Fixed #1235 (CheckMemoryLeakInFunction: Wrong handling of 'fcloseall')
This commit is contained in:
parent
83545ab11f
commit
686137415f
|
@ -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");
|
||||
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue