windows.cfg: Fixed configuration of _tfopen_s/_wfopen_s (

This commit is contained in:
PKEuS 2016-06-02 09:41:01 +02:00
parent 9a61559eca
commit 3916cd628e
2 changed files with 21 additions and 2 deletions

View File

@ -985,8 +985,8 @@
<resource>
<alloc init="true">_wfopen</alloc>
<alloc init="true">_tfopen</alloc>
<alloc init="true">_wfopen_s</alloc>
<alloc init="true">_tfopen_s</alloc>
<alloc init="true" arg="1">_wfopen_s</alloc>
<alloc init="true" arg="1">_tfopen_s</alloc>
<dealloc>fclose</dealloc>
</resource>
<memory>

View File

@ -5977,6 +5977,7 @@ private:
LOAD_LIB_2(settings.library, "windows.cfg");
TEST_CASE(openfileNoLeak);
TEST_CASE(returnValueNotUsed_tfopen_s);
}
void openfileNoLeak() {
@ -5992,6 +5993,24 @@ private:
"}");
TODO_ASSERT_EQUALS("", "[test.c:1]: (error) Resource leak: hFile\n", errout.str());
}
void returnValueNotUsed_tfopen_s() {
check("bool LoadFile(LPCTSTR filename) {\n"
" FILE *fp = NULL;\n"
" _tfopen_s(&fp, filename, _T(\"rb\"));\n"
" if (!fp)\n"
" return false;\n"
" fclose(fp);\n"
" return true;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("bool LoadFile(LPCTSTR filename) {\n"
" FILE *fp = NULL;\n"
" _tfopen_s(&fp, filename, _T(\"rb\"));\n"
"}");
TODO_ASSERT_EQUALS("[test.c:3]: (error) Resource leak: fp\n", "", errout.str());
}
};
REGISTER_TEST(TestMemleakWindows)