From 11875875213a15c6237858104736a19afcd9fdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 13 Nov 2009 20:22:28 +0100 Subject: [PATCH] Fixed #919 (possible memory leak not detected) --- lib/checkmemoryleak.cpp | 2 +- test/testmemleak.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 0e446b46d..263ebb7ff 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -1268,7 +1268,7 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all) // Otherwise, only the "if" will be deleted else if (Token::Match(tok2, "[;{}] if assign|dealloc|use ; !!else")) { - if (_settings->_showAll && !Token::simpleMatch(tok2->tokAt(2), "dealloc ; dealloc")) + if (_settings->_showAll && tok2->tokAt(2)->str() != "assign" && !Token::simpleMatch(tok2->tokAt(2), "dealloc ; dealloc")) { Token::eraseTokens(tok2, tok2->tokAt(3)); all = true; diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index ec51011b4..5c4c9e475 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -488,6 +488,7 @@ private: ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { dealloc; return; }")); ASSERT_EQUALS("; alloc ;", simplifycode("; alloc; if { return use; }")); ASSERT_EQUALS("; alloc ; return ;", simplifycode(";alloc;if{return;}return;")); + ASSERT_EQUALS("; alloc ; assign ; dealloc ;", simplifycode(";alloc;if{assign;}dealloc;")); // switch.. ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;"));