svn commit: r1933386 - subversion/trunk/subversion/libsvn_subr

[email protected]
Newsgroups gmane.comp.version-control.subversion.svn
Message-ID <177729368222.3533722.2815363493051480492@svn03-he-fi>
Author: ivan
Date: Mon Apr 27 12:41:21 2026
New Revision: 1933386

Log:
Correctly add '\0' to svn_stringbuf_t result in
svn_subr__win32_xlate_to_stringbuf().

All svn_stringbuf_t objects are expected to have their data null-terminated,
which wasn't the case with this function.

There were no real problem in the code because function is private and all
callers add '\0' to svn_stringbuf_t returned from
svn_subr__win32_xlate_to_stringbuf().

* subversion/libsvn_subr/win32_xlate.c
  (svn_subr__win32_xlate_to_stringbuf): Use calculated buffer length as
   destination length parameter when calling WideCharToMultiByte(). Set
   *DEST->DATA[len] to '\0'.

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

Modified: subversion/trunk/subversion/libsvn_subr/win32_xlate.c
==============================================================================
--- subversion/trunk/subversion/libsvn_subr/win32_xlate.c	Mon Apr 27 12:31:35 2026	(r1933385)
+++ subversion/trunk/subversion/libsvn_subr/win32_xlate.c	Mon Apr 27 12:41:21 2026	(r1933386)
@@ -237,13 +237,14 @@ svn_subr__win32_xlate_to_stringbuf(svn_s
   /* Ensure that buffer is enough to hold result string and termination
      character. */
   *dest = svn_stringbuf_create_ensure(retval + 1, pool);
-  (*dest)->len = retval;
 
   retval = WideCharToMultiByte(handle->to_page_id, 0, wide_str, wide_size,
-                               (*dest)->data, (*dest)->len, NULL, NULL);
+                               (*dest)->data, retval, NULL, NULL);
   if (retval == 0)
     return apr_get_os_error();
 
+  /* The data in svn_stringbuf_t is always NUL terminated string. */
+  (*dest)->data[retval] = '\0';
   (*dest)->len = retval;
   return APR_SUCCESS;
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.