diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 2bd846a51..bd49b6975 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -2495,8 +2495,8 @@ void CheckMemoryLeakInClass::variable(const std::string &classname, const Token Dealloc = dealloc; } - // Function call in destructor .. possible deallocation - else if (destructor && Token::Match(tok->previous(), "[{};] %var% (")) + // Function call .. possible deallocation + else if (Token::Match(tok->previous(), "[{};] %var% (")) { if (!std::bsearch(tok->str().c_str(), call_func_white_list, sizeof(call_func_white_list) / sizeof(call_func_white_list[0]), diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index fa3a5e222..d7441c342 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -2851,6 +2851,7 @@ private: TEST_CASE(class15); TEST_CASE(class16); TEST_CASE(class17); + TEST_CASE(class18); TEST_CASE(staticvar); @@ -3223,6 +3224,23 @@ private: ASSERT_EQUALS("", errout.str()); } + void class18() + { + // Ticket #853 + check("class A : public x\n" + "{\n" + "public:\n" + " A()\n" + " {\n" + " a = new char[10];\n" + " foo(a);\n" + " }\n" + "private:\n" + " char *a;\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + void staticvar() { check("class A\n"