From 7af465e6e0701eb6bd529ddc039d32a4e2346b73 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 16 Aug 2002 13:37:48 +0000 Subject: * generic/tclIOUtil.c (SetFsPathFromAny): Objects should only have their old representation deleted when we know that we are about to install a new one. This stops a weird TclX bug under Linux with certain kinds of memory debugging enabled which essentally came down to a double-free of a string. --- ChangeLog | 8 ++++++++ generic/tclIOUtil.c | 26 +++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3a4b6f..0daadde 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-08-16 Donal K. Fellows + + * generic/tclIOUtil.c (SetFsPathFromAny): Objects should only have + their old representation deleted when we know that we are about to + install a new one. This stops a weird TclX bug under Linux with + certain kinds of memory debugging enabled which essentally came + down to a double-free of a string. + 2002-08-14 Miguel Sofer * generic/tclInt.h: diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index e7ac3a2..334c569 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -17,7 +17,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIOUtil.c,v 1.64 2002/07/22 16:57:47 vincentdarley Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.65 2002/08/16 13:37:49 dkf Exp $ */ #include "tclInt.h" @@ -3842,24 +3842,6 @@ SetFsPathFromAny(interp, objPtr) return TCL_OK; } - /* Free old representation */ - if (objPtr->typePtr != NULL) { - if (objPtr->bytes == NULL) { - if (objPtr->typePtr->updateStringProc == NULL) { - if (interp != NULL) { - Tcl_ResetResult(interp); - Tcl_AppendResult(interp, "can't find object", - "string representation", (char *) NULL); - } - return TCL_ERROR; - } - objPtr->typePtr->updateStringProc(objPtr); - } - if ((objPtr->typePtr->freeIntRepProc) != NULL) { - (*objPtr->typePtr->freeIntRepProc)(objPtr); - } - } - /* * First step is to translate the filename. This is similar to * Tcl_TranslateFilename, but shouldn't convert everything to @@ -3980,6 +3962,12 @@ SetFsPathFromAny(interp, objPtr) fsPathPtr->fsRecPtr = NULL; fsPathPtr->filesystemEpoch = theFilesystemEpoch; + /* + * Free old representation before installing our new one. + */ + if (objPtr->typePtr != NULL && objPtr->typePtr->freeIntRepProc != NULL) { + (objPtr->typePtr->freeIntRepProc)(objPtr); + } objPtr->internalRep.otherValuePtr = (VOID *) fsPathPtr; objPtr->typePtr = &tclFsPathType; -- cgit v0.12