diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index fd47650e4..6a792b56a 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -988,6 +988,22 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all) tok2 = tokEnd; } + // If "--all" is given, remove all "callfunc".. + if (_settings->_showAll) + { + Token *tok2 = tok; + while (tok2) + { + if (tok2->str() == "callfunc") + { + tok2->deleteThis(); + all = true; + } + else + tok2 = tok2->next(); + } + } + // reduce the code.. bool done = false; while (! done) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 7ce92577a..c81dbb358 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -254,6 +254,7 @@ private: TEST_CASE(unknownFunction1); TEST_CASE(unknownFunction2); TEST_CASE(unknownFunction3); + TEST_CASE(unknownFunction4); // VCL.. TEST_CASE(vcl1); @@ -1951,6 +1952,18 @@ private: ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str()); } + void unknownFunction4() + { + check("void foo()\n" + "{\n" + " int *p = new int[100];\n" + " a();\n" + " if (b) return;\n" + " delete [] p;\n" + "}\n", true); + ASSERT_EQUALS("[test.cpp:5]: (all) Memory leak: p\n", errout.str()); + } + void checkvcl(const char code[], const char _autoDealloc[])