summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2024-08-23 08:10:20 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2024-08-23 08:10:20 (GMT)
commitd472e9ae5561f7d7f6e8b6b2de6efd6a56fa79ba (patch)
tree7fc78279badf58ebccb0490dcf3a0a1950d6ee3b /generic/tclEncoding.c
parente3f4e1187fee73ffe66ff7924ed2f09b4db5cc61 (diff)
downloadtcl-d472e9ae5561f7d7f6e8b6b2de6efd6a56fa79ba.zip
tcl-d472e9ae5561f7d7f6e8b6b2de6efd6a56fa79ba.tar.gz
tcl-d472e9ae5561f7d7f6e8b6b2de6efd6a56fa79ba.tar.bz2
Also fix charlimit for cesu-8
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 8af87d3..3f86857 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2469,7 +2469,12 @@ UtfToUtfProc(
dstStart = dst;
flags |= PTR2INT(clientData);
- dstEnd = dst + dstLen - ((flags & ENCODING_UTF) ? TCL_UTF_MAX : 6);
+
+ /*
+ * If output is UTF-8 or encoding for Tcl's internal encoding,
+ * max space needed is TCL_UTF_MAX. Otherwise, need 6 bytes (CESU-8)
+ */
+ dstEnd = dst + dstLen - ((flags & (ENCODING_INPUT|ENCODING_UTF)) ? TCL_UTF_MAX : 6);
/*
* Macro to output an isolated high surrogate when it is not followed