File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,6 +94,8 @@ class TestLeakAutoVar : public TestFixture {
9494 TEST_CASE (configuration2);
9595 TEST_CASE (configuration3);
9696 TEST_CASE (configuration4);
97+
98+ TEST_CASE (ptrptr);
9799 }
98100
99101 void check (const char code[]) {
@@ -545,6 +547,13 @@ class TestLeakAutoVar : public TestFixture {
545547 " }" );
546548 ASSERT_EQUALS (" [test.c:4]: (information) set_data configuration is needed to establish if there is a leak or not\n " , errout.str ());
547549 }
550+
551+ void ptrptr () {
552+ check (" void f() {\n "
553+ " char **p = malloc(10);\n "
554+ " }" );
555+ ASSERT_EQUALS (" [test.c:3]: (error) Memory leak: p\n " , errout.str ());
556+ }
548557};
549558
550559REGISTER_TEST (TestLeakAutoVar)
Original file line number Diff line number Diff line change @@ -353,6 +353,8 @@ class TestMemleakInFunction : public TestFixture {
353353 TEST_CASE (trac1879);
354354
355355 TEST_CASE (garbageCode);
356+
357+ TEST_CASE (ptrptr);
356358 }
357359
358360
@@ -3800,6 +3802,15 @@ class TestMemleakInFunction : public TestFixture {
38003802 " }" );
38013803 }
38023804
3805+ void ptrptr () {
3806+ check (" void f() {\n "
3807+ " char *p;\n "
3808+ " char **pp = &p;\n "
3809+ " *pp = calloc(10);\n "
3810+ " }" );
3811+ ASSERT_EQUALS (" [test.cpp:5]: (error) Memory leak: p\n " , errout.str ());
3812+ }
3813+
38033814};
38043815
38053816static TestMemleakInFunction testMemleakInFunction;
You can’t perform that action at this time.
0 commit comments