From c3954afdeff33ff5fc9266580fd7ae09e619439e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 28 Dec 2008 21:24:51 +0000 Subject: [PATCH] Memory leak : Remove false positive for "if (cond1) str=strdup(); if (cond2) str=strdup();" --- checkmemoryleak.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/checkmemoryleak.cpp b/checkmemoryleak.cpp index 0a92cdaf9..363f2ba4d 100644 --- a/checkmemoryleak.cpp +++ b/checkmemoryleak.cpp @@ -697,6 +697,13 @@ void CheckMemoryLeakClass::simplifycode(TOKEN *tok) done = false; } + // Two "if alloc ;" after one another.. perhaps only one of them can be executed each time + else if (!_settings._showAll && TOKEN::Match(tok2, "[;{}] if alloc ; if alloc ;")) + { + erase(tok2, tok2->tokAt(4)); + done = false; + } + // TODO Make this more generic. Delete "if ; else use ; use" else if ( TOKEN::Match(tok2, "; if ; else assign|use ; assign|use") || TOKEN::Match(tok2, "; if assign|use ; else ; assign|use") )