curlx_convert_wchar_to_UTF8 must be freed by curlx_unicodefree, but
prior to this change some uses mistakenly called free.
I've reviewed all other uses of curlx_convert_wchar_to_UTF8 and
curlx_convert_UTF8_to_wchar.
Ref: https://github.com/curl/curl/commit/
1d5d0ae
Closes https://github.com/curl/curl/pull/8521
#ifdef _UNICODE
if(filename_w) {
result = _wopen(filename_w, oflag, pmode);
- free(filename_w);
+ curlx_unicodefree(filename_w);
}
else
errno = EINVAL;
result = _wfopen(filename_w, mode_w);
else
errno = EINVAL;
- free(filename_w);
- free(mode_w);
+ curlx_unicodefree(filename_w);
+ curlx_unicodefree(mode_w);
return result;
#else
return (fopen)(filename, mode);
#else
result = _wstati64(path_w, buffer);
#endif
- free(path_w);
+ curlx_unicodefree(path_w);
}
else
errno = EINVAL;
wchar_t *path_w = curlx_convert_UTF8_to_wchar(path);
if(path_w) {
result = _waccess(path_w, mode);
- free(path_w);
+ curlx_unicodefree(path_w);
}
else
errno = EINVAL;
if(in_w) {
wchar_t punycode[IDN_MAX_LENGTH];
int chars = IdnToAscii(0, in_w, -1, punycode, IDN_MAX_LENGTH);
- free(in_w);
+ curlx_unicodefree(in_w);
if(chars) {
- *out = curlx_convert_wchar_to_UTF8(punycode);
- if(*out)
- success = TRUE;
+ char *mstr = curlx_convert_wchar_to_UTF8(punycode);
+ if(mstr) {
+ *out = strdup(mstr);
+ curlx_unicodefree(mstr);
+ if(*out)
+ success = TRUE;
+ }
}
}
wchar_t unicode[IDN_MAX_LENGTH];
int chars = IdnToUnicode(0, in_w, curlx_uztosi(in_len),
unicode, IDN_MAX_LENGTH);
- free(in_w);
+ curlx_unicodefree(in_w);
if(chars) {
- *out = curlx_convert_wchar_to_UTF8(unicode);
- if(*out)
- success = TRUE;
+ char *mstr = curlx_convert_wchar_to_UTF8(unicode);
+ if(mstr) {
+ *out = strdup(mstr);
+ curlx_unicodefree(mstr);
+ if(*out)
+ success = TRUE;
+ }
}
}
res_len = SearchPath(NULL, bundle_file, NULL, PATH_MAX, buf, &ptr);
if(res_len > 0) {
+ char *mstr = curlx_convert_tchar_to_UTF8(buf);
Curl_safefree(config->cacert);
-#ifdef UNICODE
- config->cacert = curlx_convert_wchar_to_UTF8(buf);
-#else
- config->cacert = strdup(buf);
-#endif
+ if(mstr)
+ config->cacert = strdup(mstr);
+ curlx_unicodefree(mstr);
if(!config->cacert)
result = CURLE_OUT_OF_MEMORY;
}