diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 1cc8df872..afeec8a3c 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -94,6 +94,8 @@ private: TEST_CASE(configuration2); TEST_CASE(configuration3); TEST_CASE(configuration4); + + TEST_CASE(ptrptr); } void check(const char code[]) { @@ -545,6 +547,13 @@ private: "}"); ASSERT_EQUALS("[test.c:4]: (information) set_data configuration is needed to establish if there is a leak or not\n", errout.str()); } + + void ptrptr() { + check("void f() {\n" + " char **p = malloc(10);\n" + "}"); + ASSERT_EQUALS("[test.c:3]: (error) Memory leak: p\n", errout.str()); + } }; REGISTER_TEST(TestLeakAutoVar) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index e06b83695..db8b27b46 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -353,6 +353,8 @@ private: TEST_CASE(trac1879); TEST_CASE(garbageCode); + + TEST_CASE(ptrptr); } @@ -3800,6 +3802,15 @@ private: "}"); } + void ptrptr() { + check("void f() {\n" + " char *p;\n" + " char **pp = &p;\n" + " *pp = calloc(10);\n" + "}"); + ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str()); + } + }; static TestMemleakInFunction testMemleakInFunction;