File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ class TestLeakAutoVar : public TestFixture {
108108 TEST_CASE (doublefree15);
109109 TEST_CASE (doublefree16);
110110 TEST_CASE (doublefree17); // #8109: delete with comma operator
111+ TEST_CASE (doublefree18);
111112
112113 // exit
113114 TEST_CASE (exit1);
@@ -1801,6 +1802,18 @@ class TestLeakAutoVar : public TestFixture {
18011802 ASSERT_EQUALS (" [test.cpp:5:5] -> [test.cpp:6:16]: (error) Memory pointed to by 'c' is freed twice. [doubleFree]\n " , errout_str ());
18021803 }
18031804
1805+ void doublefree18 () {
1806+ check (" typedef struct {\n " // #13918
1807+ " FILE * fp;\n "
1808+ " } S;\n "
1809+ " void f(S* s, FILE* x) {\n "
1810+ " if (fclose(s->fp)) {}\n "
1811+ " s->fp = x;\n "
1812+ " if (fclose(s->fp)) {}\n "
1813+ " }\n " );
1814+ ASSERT_EQUALS (" " , errout_str ());
1815+ }
1816+
18041817 void exit1 () {
18051818 check (" void f() {\n "
18061819 " char *p = malloc(10);\n "
You can’t perform that action at this time.
0 commit comments