summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclEncoding.c9
-rw-r--r--tests/encoding.test10
2 files changed, 19 insertions, 0 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 624705d..ee80ba4 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -3983,6 +3983,15 @@ EscapeFromUtfProc(
break;
}
len = TclUtfToUniChar(src, &ch);
+ if (ch > 0xFFFF) {
+ /* Bug 201c7a3aa6 crash - tables are 256x256 (64K) */
+ if (PROFILE_STRICT(flags)) {
+ result = TCL_CONVERT_SYNTAX;
+ break;
+ }
+ /* Will be encoded as encoding specific replacement below */
+ ch = UNICODE_REPLACE_CHAR;
+ }
word = tableFromUnicode[(ch >> 8)][ch & 0xFF];
if ((word == 0) && (ch != 0)) {
diff --git a/tests/encoding.test b/tests/encoding.test
index e18e0f1..58f0956 100644
--- a/tests/encoding.test
+++ b/tests/encoding.test
@@ -1176,7 +1176,17 @@ test encoding-bug-66ffafd309-2-replace {Bug [66ffafd309] - invalid DBCS} -body {
encoding convertfrom -profile replace jis0208 \x78\x79
} -result \uFFFD\uFFFD
+test encoding-bug-201c7a3aa6-strict {Crash encoding non-BMP to iso2022} -body {
+ encoding convertto -profile strict iso2022 \U1f600
+} -result {unexpected character at index 0: 'U+01F600'} -returnCodes error
+test encoding-bug-201c7a3aa6-replace {Crash encoding non-BMP to iso2022} -body {
+ encoding convertto -profile replace iso2022 \U1f600
+} -result ?
+
+test encoding-bug-201c7a3aa6-tcl8 {Crash encoding non-BMP to iso2022} -body {
+ encoding convertto -profile tcl8 iso2022 \U1f600
+} -result ?
# cleanup
namespace delete ::tcl::test::encoding