summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-15 09:41:03 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-11-15 09:41:03 (GMT)
commite00ef49560bb5bd4349d017887c7cd5a2d0ba38e (patch)
treeac3011b78c83bee36277f74ac8ce73b47cb1d606 /generic/tclEncoding.c
parent4a0d55e4c90514af7ad345fdc8a3e5c54100197c (diff)
downloadtcl-e00ef49560bb5bd4349d017887c7cd5a2d0ba38e.zip
tcl-e00ef49560bb5bd4349d017887c7cd5a2d0ba38e.tar.gz
tcl-e00ef49560bb5bd4349d017887c7cd5a2d0ba38e.tar.bz2
Protect additional Tcl_UtfToUniChar() call, for the case when not enough bytes are available in the buffer any more.
Add additional test-cases for those situations (upper surrogate followed by somthing other than lower surrogate)
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 00b97f5..9e1d262 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -2365,7 +2365,7 @@ UtfToUtfProc(
if ((*chPtr & 0xFC00) == 0xD800) {
/* A high surrogate character is detected, handle especially */
Tcl_UniChar low = *chPtr;
- size_t len = Tcl_UtfToUniChar(src, &low);
+ size_t len = (src <= srcEnd-3) ? Tcl_UtfToUniChar(src, &low) : 0;
if ((low & 0xFC00) != 0xDC00) {
*dst++ = (char) (((*chPtr >> 12) | 0xE0) & 0xEF);
*dst++ = (char) (((*chPtr >> 6) | 0x80) & 0xBF);