diff --git a/cfg/std.cfg b/cfg/std.cfg index 69cb06145..79dd597e0 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -1867,6 +1867,7 @@ false + diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 6e7d218c5..5578a73fa 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -1741,6 +1741,24 @@ private: "}\n", s); ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: temp\n", errout.str()); + check("FILE* f() {\n" + " char* temp = strdup(\"temp.txt\");\n" + " FILE* fp = NULL;\n" + " fopen_s(&fp, temp, \"rt\");\n" + " return fp;\n" + "}\n", s); + ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: temp\n", errout.str()); + + check("void f() {\n" + " char* temp = strdup(\"temp.txt\");\n" + " FILE* fp = fopen(\"a.txt\", \"rb\");\n" + " if (fp)\n" + " freopen(temp, \"rt\", fp);\n" + "}\n", s); + ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: temp\n" + "[test.cpp:6]: (error) Resource leak: fp\n", + errout.str()); + check("FILE* f() {\n" " char* temp = strdup(\"temp.txt\");\n" " return fopen(temp, \"rt\");\n"