summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorandreas_kupries <andreas_kupries@noemail.net>2002-01-21 20:38:06 (GMT)
committerandreas_kupries <andreas_kupries@noemail.net>2002-01-21 20:38:06 (GMT)
commit483f2761e412527159e14958837b5c7e79234b5a (patch)
treeb55eec77eccf5f16f69e282f66eca0af288d3ee5 /generic/tclIO.c
parentd2e6b6953d1a6c14a417615172f68389da5cdc02 (diff)
downloadtcl-483f2761e412527159e14958837b5c7e79234b5a.zip
tcl-483f2761e412527159e14958837b5c7e79234b5a.tar.gz
tcl-483f2761e412527159e14958837b5c7e79234b5a.tar.bz2
* generic/tclIO.c (WriteChars): Fix for SF #506297, reported by
Martin Forssen <ruric@users.sourceforge.net>. The encoding chosen in the script exposing the bug writes out three intro characters when TCL_ENCODING_START is set, but does not consume any input as TCL_ENCODING_END is cleared. As some output was generated the enclosing loop calls UtfToExternal again, again with START set. Three more characters in the out and still no use of input ... To break this infinite loop we remove TCL_ENCODING_START from the set of flags after the first call (no condition is required, the later calls remove an unset flag, which is a no-op). This causes the subsequent calls to UtfToExternal to consume and convert the actual input. FossilOrigin-Name: 1b53b7b70c86dd98ab6775792ddd47f76248112c
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 8b67405..d341261 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.47 2002/01/17 04:37:33 dgp Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.48 2002/01/21 20:38:06 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -3129,6 +3129,24 @@ WriteChars(chanPtr, src, srcLen)
Tcl_UtfToExternal(NULL, encoding, stage, stageLen, flags,
&statePtr->outputEncodingState, dst,
dstLen + BUFFER_PADDING, &stageRead, &dstWrote, NULL);
+
+ /* Fix for SF #506297, reported by Martin Forssen <ruric@users.sourceforge.net>.
+ *
+ * The encoding chosen in the script exposing the bug
+ * writes out three intro characters when
+ * TCL_ENCODING_START is set, but does not consume any
+ * input as TCL_ENCODING_END is cleared. As some output
+ * was generated the enclosing loop calls UtfToExternal
+ * again, again with START set. Three more characters in
+ * the out and still no use of input ... To break this
+ * infinite loop we remove TCL_ENCODING_START from the set
+ * of flags after the first call (no condition is
+ * required, the later calls remove an unset flag, which
+ * is a no-op). This causes the subsequent calls to
+ * UtfToExternal to consume and convert the actual input.
+ */
+
+ flags &= ~TCL_ENCODING_START;
if (stageRead + dstWrote == 0) {
/*
* We have an incomplete UTF-8 character at the end of the