fopen_utf8: nullptr crashfix

This commit is contained in:
SimpleTease 2020-12-23 03:26:29 +00:00 committed by GitHub
parent 7d313647ae
commit d2916dcd53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,9 +49,14 @@ void *fopen_utf8(const char * filename, const char * mode)
#else
wchar_t * filename_w = utf8_to_utf16_string_alloc(filename);
wchar_t * mode_w = utf8_to_utf16_string_alloc(mode);
FILE* ret = _wfopen(filename_w, mode_w);
free(filename_w);
free(mode_w);
FILE* ret = NULL;
if (filename_w && mode_w)
ret = _wfopen(filename_w, mode_w);
if (filename_w)
free(filename_w);
if (mode_w)
free(mode_w);
return ret;
#endif
}