From 0e512ef79291d7d330694670a5bf967343f0e1a7 Mon Sep 17 00:00:00 2001 From: das Date: Tue, 11 Mar 2008 22:25:12 +0000 Subject: * generic/tclEncoding.c (LoadEscapeEncoding): avoid leaking escape sub-encodings, fixes encoding-11.1 failing after iso2022-jp loaded (e.g. TESTFLAGS='-singleproc 1 -match "chan-io-1.8 encoding-11.1"'). --- generic/tclEncoding.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 930d11d..95f89a4 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.58 2007/12/13 15:23:16 dgp Exp $ + * RCS: @(#) $Id: tclEncoding.c,v 1.59 2008/03/11 22:25:12 das Exp $ */ #include "tclInt.h" @@ -1972,6 +1972,7 @@ LoadEscapeEncoding( final[sizeof(final) - 1] = '\0'; } else { EscapeSubTable est; + Encoding *e; strncpy(est.sequence, argv[1], sizeof(est.sequence)); est.sequence[sizeof(est.sequence) - 1] = '\0'; @@ -1984,9 +1985,13 @@ LoadEscapeEncoding( * To avoid infinite recursion in [encoding system iso2022-*] */ - Tcl_GetEncoding(NULL, est.name); - - est.encodingPtr = NULL; + e = (Encoding *) Tcl_GetEncoding(NULL, est.name); + if (e && e->toUtfProc != TableToUtfProc && + e->toUtfProc != Iso88591ToUtfProc) { + Tcl_FreeEncoding((Tcl_Encoding) e); + e = NULL; + } + est.encodingPtr = e; Tcl_DStringAppend(&escapeData, (char *) &est, sizeof(est)); } } -- cgit v0.12