From a8ba28440c43aab316413eda9bc9c4de26fd971e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 14 Apr 2008 06:25:34 +0000 Subject: [PATCH] CheckMemoryLeak: Bug fix so that checking stops when the variable goes out of scope --- CheckMemoryLeak.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 0c60cd7b9..465409f5d 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -115,9 +115,10 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] else if (tok->str[0]=='}') { indentlevel--; - if ( indentlevel < 0 && Alloc != No ) + if ( indentlevel < 0 ) { - MemoryLeak( Tok1, varname ); + if ( Alloc != No ) + MemoryLeak( Tok1, varname ); return; } @@ -128,6 +129,7 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] // Skip stuff like: if (!var) ... if ( Match(tok, "if ( ! %var1% )", varnames) || Match(tok, "if ( %var1% == NULL )", varnames) || + Match(tok, "if ( NULL == %var1% )", varnames) || Match(tok, "if ( %var1% == 0 )", varnames) ) { int _indentlevel = 0;