diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index 985e9a25e..5a804189a 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -506,6 +506,8 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const st } else if (!dealloc.empty()) { alloctype[arg->varId()] = "dealloc"; } + } else if (Token::Match(arg, "%var% (")) { + functionCall(arg, varInfo, dealloc); } } } diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 97bd72da7..1cc8df872 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -43,6 +43,7 @@ private: TEST_CASE(assign8); TEST_CASE(assign9); TEST_CASE(assign10); + TEST_CASE(assign11); // #3942: x = a(b(p)); TEST_CASE(deallocuse1); TEST_CASE(deallocuse2); @@ -201,6 +202,14 @@ private: ASSERT_EQUALS("", errout.str()); } + void assign11() { // #3942 - FP for x = a(b(p)); + check("void f() {\n" + " char *p = malloc(10);\n" + " x = a(b(p));\n" + "}"); + ASSERT_EQUALS("[test.c:4]: (information) b configuration is needed to establish if there is a leak or not\n", errout.str()); + } + void deallocuse1() { check("void f(char *p) {\n" " free(p);\n"