diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index e0129af71..7dde64e84 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1465,7 +1465,8 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok) // reduce "; callfunc ; %var%" for (Token *tok2 = tok; tok2; tok2 = tok2->next()) { - if (Token::Match(tok2, ";|{|} callfunc ; %type%")) + if (Token::Match(tok2, ";|{|} callfunc ; %type%") || + Token::Match(tok2, ";|{|} callfunc ; ;")) tok2->deleteNext(); } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index f71cd1545..b25b3a6ea 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -708,6 +708,7 @@ private: // callfunc.. ASSERT_EQUALS("; callfunc ;", simplifycode(";callfunc;")); + ASSERT_EQUALS(";", simplifycode(";callfunc;;")); ASSERT_EQUALS("while1 { dealloc ; alloc ; } return ; }", simplifycode("while1 { dealloc ; alloc ; } callfunc ; return ; }")); // exit..