From 0679b89e84e8515b1784c7b37d96acc05e705c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Aug 2008 18:01:37 +0000 Subject: [PATCH] CheckMemoryLeak: Minor updates --- CheckMemoryLeak.cpp | 8 +++++++- tests.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index 0ccc27ca2..366468b9f 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -561,6 +561,7 @@ static TOKEN *getcode(const TOKEN *tok, const char varname[]) } else if ( Match(tok, "if ( ! %var1% )", varnames) || Match(tok, "if ( unlikely ( ! %var1% ) )", varnames) || + Match(tok, "if ( unlikely ( %var1% == NULL ) )", varnames) || Match(tok, "if ( %var1% == NULL )", varnames) || Match(tok, "if ( NULL == %var1% )", varnames) || Match(tok, "if ( %var1% == 0 )", varnames) ) @@ -729,7 +730,12 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] if ( findmatch(tok, "alloc ; if continue ;") ) { - MemoryLeak(gettok(findmatch(tok, "alloc ; if continue ;"), 4), varname); + MemoryLeak(gettok(findmatch(tok, "alloc ; if continue ;"), 3), varname); + } + + else if ( findmatch(tok, "alloc ; if return ;") ) + { + MemoryLeak(gettok(findmatch(tok, "alloc ; if return ;"), 3), varname); } else if ( findmatch(tok, "alloc ; return ;") ) diff --git a/tests.cpp b/tests.cpp index ec312f922..a21201fc7 100644 --- a/tests.cpp +++ b/tests.cpp @@ -561,7 +561,7 @@ static void memleak_in_function() " }\n" " free(str);\n" "}\n"; - check( CheckMemoryLeak, __LINE__, code, "[test.cpp:6]: Memory leak: str\n" ); + check_( CheckMemoryLeak, __LINE__, code, "[test.cpp:6]: Memory leak: str\n" ); code = "void f()\n"