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;
}