diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 8679353f1..8c4efd18a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1847,10 +1847,10 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok) } // Reduce "while1 continue| ;" => "use ;" - if (Token::Match(tok2, "while1 continue| ;")) + if (Token::Match(tok2, "while1 if| continue| ;")) { tok2->str("use"); - if (tok2->strAt(1) == "continue") + while (tok2->strAt(1) != ";") tok2->deleteNext(); done = false; } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 7339de4a1..ff4a124bd 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -668,6 +668,8 @@ private: ASSERT_EQUALS(";", simplifycode("; loop { if { continue ; } else { if continue ; } }")); ASSERT_EQUALS(";", simplifycode("; loop { { if continue ; if continue ; } }")); + ASSERT_EQUALS(";", simplifycode("; while1 { if { dealloc ; return ; } if { if { continue ; } } }")); + // scope.. // current result - ok ASSERT_EQUALS("; assign ; dealloc ; if alloc ; }", simplifycode("; assign ; { dealloc ; if alloc ; } }"));