From 7fff40c678507ffe82b3c65f1a0277a6da0b906e Mon Sep 17 00:00:00 2001
From: "jan.nijtmans" <nijtmans@users.sourceforge.net>
Date: Fri, 12 Jan 2018 10:03:58 +0000
Subject: [PATCH 0837/1800] Fix [11ae2be95d]: tip-389 branch: string range
 errors with code points greater than U+FFFF

---
 generic/tclExecute.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index f2cda0ca8..63281a85e 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -5445,7 +5445,7 @@ TEBCresume(
 		    valuePtr->bytes+index, 1);
 	} else {
 	    char buf[TCL_UTF_MAX];
-	    Tcl_UniChar ch = Tcl_GetUniChar(valuePtr, index);
+	    int ch = Tcl_GetUniChar(valuePtr, index);
 
 	    /*
 	     * This could be: Tcl_NewUnicodeObj((const Tcl_UniChar *)&ch, 1)
@@ -5453,7 +5453,7 @@ TEBCresume(
 	     * practical use.
 	     */
 
-	    length = Tcl_UniCharToUtf(ch, buf);
+	    length = (ch != -1) ? Tcl_UniCharToUtf(ch, buf) : 0;
 	    objResultPtr = Tcl_NewStringObj(buf, length);
 	}
 
-- 
2.19.1

