diff --git a/CheckClass.cpp b/CheckClass.cpp index b7156dac8..d639352e5 100644 --- a/CheckClass.cpp +++ b/CheckClass.cpp @@ -464,9 +464,10 @@ void CheckMemset() // Locate all 'memset' tokens.. for (const TOKEN *tok = tokens; tok; tok = tok->next) { - if (strcmp(tok->str,"memset")!=0) + if (!Match(tok,"memset") && !Match(tok,"memcpy") && !Match(tok,"memmove")) continue; + // Todo: Handle memcpy and memmove const char *type = NULL; if (Match(tok, "memset ( %var% , %num% , sizeof ( %type% ) )")) type = getstr(tok, 8); diff --git a/CheckMemoryLeak.cpp b/CheckMemoryLeak.cpp index cd1963d2a..0c60cd7b9 100644 --- a/CheckMemoryLeak.cpp +++ b/CheckMemoryLeak.cpp @@ -175,6 +175,15 @@ static void CheckMemoryLeak_CheckScope( const TOKEN *Tok1, const char varname[] if ( Match( tok, "[=,(] %var1% [,);]", varnames ) ) return; + // continue/break loop.. + if (Alloc != No && + alloc_indentlevel == indentlevel && + (Match(tok,"continue") || Match(tok,"break"))) + { + MemoryLeak( tok, varname ); + return; + } + // Return without deallocating the memory.. if ( Alloc != No && alloc_indentlevel >= 0 && Match(tok, "return") ) { diff --git a/tests.cpp b/tests.cpp index 324da9d55..3a633c4eb 100644 --- a/tests.cpp +++ b/tests.cpp @@ -472,7 +472,6 @@ static void memleak_in_function() check( CheckMemoryLeak, __LINE__, test3, "" ); -/* TODO const char test4[] = "void f()\n" "{\n" " for (int i = 0; i < j; i++)\n" @@ -483,8 +482,8 @@ static void memleak_in_function() " free(str);\n" " }\n" "}\n"; - check( CheckMemoryLeak, __LINE__, test4, "[test.cpp:7]: Memory leak:str\n" ); -*/ + check( CheckMemoryLeak, __LINE__, test4, "[test.cpp:7]: Memory leak: str\n" ); +