diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 8c290ea87..9108e406a 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -3075,6 +3075,11 @@ void CheckMemoryLeakNoVar::check() if (Token::Match(tok3->tokAt(-2), "[(,;{}] %var% (")) { const std::string functionName = tok3->strAt(-1); + if (functionName == "delete" || + functionName == "free" || + functionName == "fclose" || + functionName == "realloc") + break; if (CheckMemoryLeakInFunction::test_white_list(functionName)) { functionCallLeak(tok2, tok2->strAt(1), functionName); diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 46af1ed11..f94228523 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -4413,6 +4413,11 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:2]: (error) Allocation with strdup, strcpy doesn't release it.\n", errout.str()); + check("void x() {\n" + " free(malloc(10));\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // user function.. check("void set_error(const char *msg) {\n" "}\n"