summaryrefslogtreecommitdiffstats
path: root/generic/tclEncoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclEncoding.c')
-rw-r--r--generic/tclEncoding.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 783e3d3..7abb402 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.41 2006/03/24 21:11:45 dgp Exp $
+ * RCS: @(#) $Id: tclEncoding.c,v 1.42 2006/04/05 00:18:50 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -2225,6 +2225,16 @@ UtfToUtfProc(
*dst++ = 0;
src += 2;
+ } else if (!Tcl_UtfCharComplete(src, srcEnd - src)) {
+ /* Always check before using Tcl_UtfToUniChar. Not doing
+ * can so cause it run beyond the endof the buffer! If we
+ * * happen such an incomplete char its byts are made to *
+ * represent themselves.
+ */
+
+ ch = (Tcl_UniChar) *src;
+ src += 1;
+ dst += Tcl_UniCharToUtf(ch, dst);
} else {
src += Tcl_UtfToUniChar(src, &ch);
dst += Tcl_UniCharToUtf(ch, dst);