]> git.ipfire.org Git - thirdparty/curl.git/commit
curl_multibyte: always return a heap-allocated copy of string
authorJay Satiro <raysatiro@yahoo.com>
Sat, 13 Feb 2021 05:51:28 +0000 (00:51 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Sat, 20 Feb 2021 19:39:39 +0000 (14:39 -0500)
commit09363500b9e161670b6bd084cc57bff75d32fc02
treebcf93fa61086156f9754977360438c783981f37a
parentf65d7889b5c8eeefbb9f41c7588199be18b38a20
curl_multibyte: always return a heap-allocated copy of string

- Change the Windows char <-> UTF-8 conversion functions to return an
  allocated copy of the passed in string instead of the original.

Prior to this change the curlx_convert_ functions would, as what I
assume was an optimization, not make a copy of the passed in string if
no conversion was required. No conversion is required in non-UNICODE
Windows builds since our tchar strings are type char and remain in
whatever the passed in encoding is, which is assumed to be UTF-8 but may
be other encoding.

In contrast the UNICODE Windows builds require conversion
(wchar <-> char) and do return a copy. That inconsistency could lead to
programming errors where the developer expects a copy, and does not
realize that won't happen in all cases.

Closes https://github.com/curl/curl/pull/6602
lib/curl_multibyte.c
lib/curl_multibyte.h