diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index d9f1bd109..99024ed9a 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -1166,7 +1166,9 @@ void CheckMemoryLeakClass::CheckMemoryLeak_CheckScope(const Token *Tok1, const c tok2->str("use"); else if (tok2->str() == "&use2" || tok2->str() == "use_") tok2->str(";"); - else if (tok2->str() == "recursive" || tok2->str() == "dealloc_") + else if (tok2->str() == "recursive") + tok2->str("use"); + else if (tok2->str() == "dealloc_") tok2->str("dealloc"); else if (tok2->str() == "realloc") { diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index c82439f40..2b5345ca2 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -167,7 +167,8 @@ private: TEST_CASE(dealloc_use_6); // free a free'd pointer - TEST_CASE(freefree); + TEST_CASE(freefree1); + TEST_CASE(freefree2); } @@ -1591,7 +1592,7 @@ private: } - void freefree() + void freefree1() { check("void foo()\n" "{\n" @@ -1602,6 +1603,17 @@ private: ASSERT_EQUALS(std::string("[test.cpp:5]: Deallocating a deallocated pointer\n"), errout.str()); } + void freefree2() + { + check("void foo()\n" + "{\n" + " FILE *fd = fopen(\"test.txt\", \"wb\");\n" + " fprintf(fd, \"test\");\n" + " fclose(fd);\n" + "}\n"); + ASSERT_EQUALS(std::string(""), errout.str()); + } + }; REGISTER_TEST(TestMemleak)