Fixed #1716 (Wrong reporting of leak with close() in a while loop condition)
This commit is contained in:
parent
24703418bd
commit
495dfde32c
|
@ -1036,6 +1036,12 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (varid && getDeallocationType(tok->tokAt(2), varid) != No)
|
||||||
|
{
|
||||||
|
addtoken("dealloc");
|
||||||
|
addtoken(";");
|
||||||
|
}
|
||||||
|
|
||||||
else if (alloctype == Fd && varid)
|
else if (alloctype == Fd && varid)
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "while ( 0 <= %varid% )", varid) ||
|
if (Token::Match(tok, "while ( 0 <= %varid% )", varid) ||
|
||||||
|
|
|
@ -522,6 +522,7 @@ private:
|
||||||
// open/close
|
// open/close
|
||||||
ASSERT_EQUALS(";;alloc;if(var){dealloc;}", getcode("int f; f=open(); if(f>=0)close(f);", "f"));
|
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(";;alloc;ifv{;}", getcode("int f; f=open(); if(f!=-1 || x);", "f"));
|
||||||
|
ASSERT_EQUALS(";;;dealloc;loop{}}", getcode(";int f; while (close(f) == -1) { } }", "f"));
|
||||||
|
|
||||||
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
|
ASSERT_EQUALS(";;dealloc;", getcode("int f; e |= fclose(f);", "f"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue