Fixed #3671 (False positive: Resource leak: fd)
This commit is contained in:
parent
29063098bf
commit
1e125dc017
|
@ -1055,7 +1055,7 @@ Token *CheckMemoryLeakInFunction::getcode(const Token *tok, std::list<const Toke
|
|||
// if else switch
|
||||
if (Token::simpleMatch(tok, "if (")) {
|
||||
if (alloctype == Fd) {
|
||||
if (Token::Match(tok, "if ( 0 <=|< %varid% )", varid) ||
|
||||
if (Token::Match(tok, "if ( 0|-1 <=|< %varid% )", varid) ||
|
||||
Token::Match(tok, "if ( %varid% != -1 )", varid)) {
|
||||
addtoken(&rettail, tok, "if(var)");
|
||||
tok = tok->next()->link();
|
||||
|
|
|
@ -520,6 +520,7 @@ private:
|
|||
|
||||
// open/close
|
||||
ASSERT_EQUALS(";;alloc;if(var){dealloc;}", getcode("int f; f=open(a,b); if(f>=0)close(f);", "f"));
|
||||
ASSERT_EQUALS(";;alloc;if(var){dealloc;}", getcode("int f; f=open(a,b); if(f>-1)close(f);", "f"));
|
||||
ASSERT_EQUALS(";;alloc;ifv{;}", getcode("int f; f=open(a,b); if(f!=-1 || x);", "f"));
|
||||
ASSERT_EQUALS(";;;dealloc;loop{}}", getcode(";int f; while (close(f) == -1) { } }", "f"));
|
||||
ASSERT_EQUALS(";;;dealloc;assign;;}", getcode(";int res; res = close(res); }", "res"));
|
||||
|
|
Loading…
Reference in New Issue