summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2023-07-04 06:47:13 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2023-07-04 06:47:13 (GMT)
commit3d2de6ed070b76c6a985c1cfe0be7a50fb12b650 (patch)
treebd49cfee553275e410409fbb0c0f59ed0daab12d
parentf24bab84df2f1940c0a8004c4ee69c3c48da3126 (diff)
downloadtcl-3d2de6ed070b76c6a985c1cfe0be7a50fb12b650.zip
tcl-3d2de6ed070b76c6a985c1cfe0be7a50fb12b650.tar.gz
tcl-3d2de6ed070b76c6a985c1cfe0be7a50fb12b650.tar.bz2
Correctly compute consumed bytes in case of truncated byte sequence at end.
-rw-r--r--generic/tclEncoding.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index d0f04a7..42fcb7f 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -3448,6 +3448,14 @@ TableToUtfProc(
src++;
}
+ if (src > srcEnd) {
+ /*
+ * This can happen in the case of a trailing truncated byte sequence
+ * where src is incremented past the prefix byte which is the last.
+ * See bug [5be203d6ca]
+ */
+ src--;
+ }
*srcReadPtr = src - srcStart;
*dstWrotePtr = dst - dstStart;
*dstCharsPtr = numChars;