diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-02-27 21:29:43 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-02-27 21:29:43 (GMT) |
commit | 050b6c3d5f632fea7bf549688c54be65fba7bee2 (patch) | |
tree | 007b045355fdadddb97c53f8d0d714ef29a351ed /generic/tclParse.c | |
parent | f04b875d88bbe9cd4d2114d60c194be01a7c9e04 (diff) | |
parent | 57d9952ece8f81fc6802097bace965a196bb849b (diff) | |
download | tcl-050b6c3d5f632fea7bf549688c54be65fba7bee2.zip tcl-050b6c3d5f632fea7bf549688c54be65fba7bee2.tar.gz tcl-050b6c3d5f632fea7bf549688c54be65fba7bee2.tar.bz2 |
Fix [bd94500678e837d7]: SEGFAULT by conversion of unicode (out of BMP) to byte-array
Diffstat (limited to 'generic/tclParse.c')
-rw-r--r-- | generic/tclParse.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/generic/tclParse.c b/generic/tclParse.c index 1eb4e6a..2419026 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -791,7 +791,7 @@ TclParseBackslash( Tcl_UniChar unichar = 0; int result; int count; - char buf[TCL_UTF_MAX]; + char buf[TCL_UTF_MAX] = ""; if (numBytes == 0) { if (readPtr != NULL) { @@ -939,9 +939,9 @@ TclParseBackslash( *readPtr = count; } count = Tcl_UniCharToUtf(result, dst); - if (!count) { + if ((result >= 0xD800) && (count < 3)) { /* Special case for handling high surrogates. */ - count = Tcl_UniCharToUtf(-1, dst); + count += Tcl_UniCharToUtf(-1, dst + count); } return count; } @@ -2151,7 +2151,7 @@ TclSubstTokens( Tcl_Obj *appendObj = NULL; const char *append = NULL; int appendByteLength = 0; - char utfCharBytes[TCL_UTF_MAX]; + char utfCharBytes[TCL_UTF_MAX] = ""; switch (tokenPtr->type) { case TCL_TOKEN_TEXT: |