Author: ivan
Date: Wed Apr 22 13:40:07 2026
New Revision: 1933247

Log:
* subversion/libsvn_subr/sysinfo.c
  (wcs_to_utf8): Use svn_utf__win32_utf16_to_utf8() instead of using
   WideCharToMultiByte() directly.

Modified:
   subversion/trunk/subversion/libsvn_subr/sysinfo.c

Modified: subversion/trunk/subversion/libsvn_subr/sysinfo.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/sysinfo.c   Wed Apr 22 13:38:03 
2026        (r1933246)
+++ subversion/trunk/subversion/libsvn_subr/sysinfo.c   Wed Apr 22 13:40:07 
2026        (r1933247)
@@ -965,15 +965,17 @@ win32_canonical_host(apr_pool_t *pool)
 static const char *
 wcs_to_utf8(const wchar_t *wcs, apr_pool_t *pool)
 {
-  const int bufsize = WideCharToMultiByte(CP_UTF8, 0, wcs, -1,
-                                          NULL, 0, NULL, NULL);
-  if (bufsize > 0)
+  svn_error_t *err;
+  const char *utf8;
+
+  err = svn_utf__win32_utf16_to_utf8(&utf8, wcs, NULL, pool);
+  if (err)
     {
-      char *const utf8 = apr_palloc(pool, bufsize + 1);
-      WideCharToMultiByte(CP_UTF8, 0, wcs, -1, utf8, bufsize, NULL, NULL);
-      return utf8;
+      svn_error_clear(err);
+      return NULL;
     }
-  return NULL;
+
+  return utf8;
 }
 
 /* Query the value called NAME of the registry key HKEY. */

Reply via email to