Skip to content

Commit be33f6b

Browse files
author
Daniel Marjamäki
committed
Fixed danmar#2635 (False positive: resource leak)
1 parent e588f20 commit be33f6b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/checkmemoryleak.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1964,8 +1964,8 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok)
19641964
}
19651965
else
19661966
{
1967-
// remove the "if* ;"
1968-
Token::eraseTokens(tok2, tok2->tokAt(3));
1967+
// remove the "if*"
1968+
Token::eraseTokens(tok2, tok2->tokAt(2));
19691969
}
19701970
done = false;
19711971
}

test/testmemleak.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,10 @@ class TestMemleakInFunction : public TestFixture
727727

728728
// use ; dealloc ;
729729
ASSERT_EQUALS("; alloc ; use ; if return ; dealloc ;", simplifycode("; alloc ; use ; if { return ; } dealloc ;"));
730+
731+
// #2635 - false negative
732+
ASSERT_EQUALS("; alloc ; return use ; }",
733+
simplifycode("; alloc ; if(!var) { loop { ifv { } } alloc ; } return use; }"));
730734
}
731735

732736

0 commit comments

Comments
 (0)