From b145bf36500eff5c3957def0d4fdb214fa1ed98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 16 Dec 2008 19:01:15 +0000 Subject: [PATCH] Memory leak : Fixed issue 2429936 - false positive reported on the break in the code "loop { dealloc ; alloc ; if break ; }" --- checkmemoryleak.cpp | 11 +++++++++++ testmemleak.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/checkmemoryleak.cpp b/checkmemoryleak.cpp index 491ad2d6f..7f89e53d3 100644 --- a/checkmemoryleak.cpp +++ b/checkmemoryleak.cpp @@ -785,6 +785,17 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok) { erase( tok2, tok2->tokAt(4) ); done = false; + } + + // Reduce "loop { assign|dealloc|use ; alloc ; if break ; }" to "assign|dealloc|use ; alloc ;" + if ( TOKEN::Match( tok2->next(), "loop { assign|dealloc|use ; alloc ; if break|continue ; }" ) ) + { + // erase "loop {" + erase( tok2, tok2->tokAt(3) ); + // erase "if break|continue ; }" + tok2 = tok2->next()->next()->next()->next(); + erase( tok2, tok2->tokAt(5) ); + done = false; } // Reduce "if(true) X ;" => "X ;" diff --git a/testmemleak.cpp b/testmemleak.cpp index c43527c08..318eaec20 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -97,7 +97,7 @@ private: TEST_CASE( forwhile5 ); TEST_CASE( forwhile6 ); TEST_CASE( forwhile7 ); - // TODO TEST_CASE( forwhile8 ); // Bug 2429936 + TEST_CASE( forwhile8 ); // Bug 2429936 TEST_CASE( dowhile1 );