From 5d132715be3ea1fc57c5b64e85e2de5c3d99fbc0 Mon Sep 17 00:00:00 2001 From: hobbs Date: Fri, 12 Nov 2004 23:41:59 +0000 Subject: * generic/tclEncoding.c (TableFromUtfProc): correct crash condition when TCL_UTF_MAX == 6. [Bug 1004065] --- ChangeLog | 5 +++++ generic/tclEncoding.c | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3ed3cba..232dcf2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-11-12 Jeff Hobbs + + * generic/tclEncoding.c (TableFromUtfProc): correct crash + condition when TCL_UTF_MAX == 6. [Bug 1004065] + 2004-11-12 Daniel Steffen * doc/clock.n: diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index d66ce37..d35cd4c 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclEncoding.c,v 1.16.2.5 2004/05/27 14:33:18 rmax Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.16.2.6 2004/11/12 23:42:00 hobbs Exp $ */ #include "tclInt.h" @@ -2350,7 +2350,18 @@ TableFromUtfProc(clientData, src, srcLen, flags, statePtr, dst, dstLen, break; } len = TclUtfToUniChar(src, &ch); - word = fromUnicode[(ch >> 8)][ch & 0xff]; + +#if TCL_UTF_MAX > 3 + /* + * This prevents a crash condition. More evaluation is required + * for full support of int Tcl_UniChar. [Bug 1004065] + */ + if (ch & 0xffff0000) { + word = 0; + } else +#endif + word = fromUnicode[(ch >> 8)][ch & 0xff]; + if ((word == 0) && (ch != 0)) { if (flags & TCL_ENCODING_STOPONERROR) { result = TCL_CONVERT_UNKNOWN; -- cgit v0.12