diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index 21b56a754..f1359768c 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -1333,7 +1333,7 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c MemoryLeak(result->tokAt(3), varname, alloctype, all); } - else if ((result = Token::findmatch(tok, "alloc ; alloc|assign|return ;")) != NULL) + else if ((result = Token::findmatch(tok, "alloc ; alloc|assign|return callfunc| ;")) != NULL) { MemoryLeak(result->tokAt(2), varname, alloctype, all); } diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index c677e93ba..dc83d4028 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1993,6 +1993,14 @@ private: " }\n" "}\n"); ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: p\n", errout.str()); + + check("void foo()\n" + "{\n" + " int *p = new int[100];\n" + " p = g();\n" + " delete [] p;\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: p\n", errout.str()); } void unknownFunction3()