summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-28 21:14:40 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-12-28 21:14:40 (GMT)
commitad43c617e3fb81c44639a400b8a6d611aa52e3f2 (patch)
tree3ab00db80ae561e18e8aba09a1ed828b5dab490d /generic
parent301f6bcb839b301e1e3d3a92e3713696780c95ca (diff)
downloadtcl-ad43c617e3fb81c44639a400b8a6d611aa52e3f2.zip
tcl-ad43c617e3fb81c44639a400b8a6d611aa52e3f2.tar.gz
tcl-ad43c617e3fb81c44639a400b8a6d611aa52e3f2.tar.bz2
Fix bug introduced in [0dd0d14489258621] (only for TCL_UTF_MAX > 3): If len parameter = -1, returned size includes terminating 0-byte. So, account for that.
Also, fix some comments which were not accurate any more, now that Windows 95/98 is not supported any more.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclStubInit.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 679a12b..b28d501 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -196,6 +196,7 @@ Tcl_WinUtfToTChar(
Tcl_DStringSetLength(dsPtr, 2*size+2);
wp = (WCHAR *)Tcl_DStringValue(dsPtr);
MultiByteToWideChar(CP_UTF8, 0, string, len, wp, size+1);
+ if (len == -1) --size; /* account for 0-byte at string end */
Tcl_DStringSetLength(dsPtr, 2*size);
wp[size] = 0;
return (char *)wp;
@@ -226,6 +227,7 @@ Tcl_WinTCharToUtf(
Tcl_DStringSetLength(dsPtr, size+1);
p = (char *)Tcl_DStringValue(dsPtr);
WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
+ if (len == -1) --size; /* account for 0-byte at string end */
Tcl_DStringSetLength(dsPtr, size);
p[size] = 0;
return p;