File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,7 @@ class TestLeakAutoVar : public TestFixture {
181181 TEST_CASE (return10);
182182 TEST_CASE (return11); // #13098
183183 TEST_CASE (return12); // #12238
184+ TEST_CASE (return13);
184185
185186 // General tests: variable type, allocation type, etc
186187 TEST_CASE (test1);
@@ -2838,6 +2839,22 @@ class TestLeakAutoVar : public TestFixture {
28382839 ASSERT_EQUALS (" " , errout_str ());
28392840 }
28402841
2842+ void return13 () { // #4638
2843+ CheckOptions options;
2844+ options.cpp = true ;
2845+ check (" bool f() {\n "
2846+ " int* p = new int;\n "
2847+ " return p;\n "
2848+ " }\n "
2849+ " bool g() {\n "
2850+ " void* p = malloc(4);\n "
2851+ " return p;\n "
2852+ " }\n " , options);
2853+ ASSERT_EQUALS (" [test.cpp:3:5]: (error) Memory leak: p [memleak]\n "
2854+ " [test.cpp:7:5]: (error) Memory leak: p [memleak]\n " ,
2855+ errout_str ());
2856+ }
2857+
28412858 void test1 () {
28422859 check (" void f(double*&p) {\n " // 3809
28432860 " p = malloc(0x100);\n "
You can’t perform that action at this time.
0 commit comments