lib: fix some misuse of curlx_convert_wchar_to_UTF8

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: 1d5d0ae

Closes https://github.com/curl/curl/pull/8521
This commit is contained in:
Jay Satiro 2022-02-28 03:12:12 -05:00
parent 45cb662b87
commit d3cb3be520
3 changed files with 25 additions and 18 deletions

View file

@ -635,12 +635,11 @@ CURLcode FindWin32CACert(struct OperationConfig *config,
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;
}