diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 3958d1de8..aa1883ee7 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -639,7 +639,7 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::liststr() != "{")) ftok = ftok->next(); Token *func = getcode(ftok->tokAt(1), callstack, parameterVarid, alloctype, dealloctype, false, all, sz); - simplifycode(func, all); + //simplifycode(func, all); const Token *func_ = func; while (func_ && func_->str() == ";") func_ = func_->next(); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 7b4f2a858..2d8f3e41a 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -295,6 +295,7 @@ private: TEST_CASE(func14); TEST_CASE(func15); TEST_CASE(func16); + TEST_CASE(func17); TEST_CASE(allocfunc1); TEST_CASE(allocfunc2); @@ -1580,6 +1581,32 @@ private: } + void func17() + { + // The "bar" function must be reduced to "use" + + check("bool bar(char **parent, char *res, bool a)\n" + "{\n" + " if( a )\n" + " {\n" + " *parent = res;\n" + " return false;\n" + " }\n" + " return true;\n" + "}\n" + "\n" + "void foo(char **parent, bool a)\n" + "{\n" + " if (a)\n" + " {\n" + " char *res = malloc(65);\n" + " bar(parent, res, a);\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + + void allocfunc1() {