From 5ea8d411b51ec01a52c241b64b3937b0960c4878 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 13 Dec 2008 08:43:22 +0000 Subject: [PATCH] Memory leak : Fixed a test where pointer is reassigned --- CheckMemoryLeak.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index ce7c41c43..bff3d3ec8 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -403,8 +403,22 @@ TOKEN *CheckMemoryLeakClass::getcode(const TOKEN *tok, std::list // assignment.. else - { - addtoken( "assign" ); + { + // is the pointer in rhs? + bool rhs = false; + for ( const TOKEN *tok2 = tok->tokAt(2); tok2; tok2 = tok2->next() ) + { + if ( tok2->str() == ";" ) + break; + + if ( tok2->str() == varname ) + { + rhs = true; + break; + } + } + + addtoken( rhs ? "use" : "assign" ); } }