diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index daf738e7b46..7aa64c1cd3c 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -181,6 +181,7 @@ class TestLeakAutoVar : public TestFixture { TEST_CASE(return10); TEST_CASE(return11); // #13098 TEST_CASE(return12); // #12238 + TEST_CASE(return13); // General tests: variable type, allocation type, etc TEST_CASE(test1); @@ -2838,6 +2839,22 @@ class TestLeakAutoVar : public TestFixture { ASSERT_EQUALS("", errout_str()); } + void return13() { // #4638 + CheckOptions options; + options.cpp = true; + check("bool f() {\n" + " int* p = new int;\n" + " return p;\n" + "}\n" + "bool g() {\n" + " void* p = malloc(4);\n" + " return p;\n" + "}\n", options); + ASSERT_EQUALS("[test.cpp:3:5]: (error) Memory leak: p [memleak]\n" + "[test.cpp:7:5]: (error) Memory leak: p [memleak]\n", + errout_str()); + } + void test1() { check("void f(double*&p) {\n" // 3809 " p = malloc(0x100);\n"