Add leak-ignore for fopen_s(), test cases (#3839)
* Add leak-ignore for fopen_s(), test cases * Format
This commit is contained in:
parent
bb8b9a8001
commit
2f46e57311
|
@ -1867,6 +1867,7 @@
|
||||||
<function name="fopen_s">
|
<function name="fopen_s">
|
||||||
<returnValue type="errno_t"/>
|
<returnValue type="errno_t"/>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
|
<leak-ignore/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-null/>
|
<not-null/>
|
||||||
</arg>
|
</arg>
|
||||||
|
|
|
@ -1741,6 +1741,24 @@ private:
|
||||||
"}\n", s);
|
"}\n", s);
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: temp\n", errout.str());
|
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"
|
check("FILE* f() {\n"
|
||||||
" char* temp = strdup(\"temp.txt\");\n"
|
" char* temp = strdup(\"temp.txt\");\n"
|
||||||
" return fopen(temp, \"rt\");\n"
|
" return fopen(temp, \"rt\");\n"
|
||||||
|
|
Loading…
Reference in New Issue