diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2002-08-16 13:37:48 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2002-08-16 13:37:48 (GMT) |
commit | 7af465e6e0701eb6bd529ddc039d32a4e2346b73 (patch) | |
tree | a5ad2df6cc3168198c1d958ad1041d6e2147e05f /generic/tclIOUtil.c | |
parent | 4b5d9d688fcfa02e6cbce01873ea40fa7fc62bde (diff) | |
download | tcl-7af465e6e0701eb6bd529ddc039d32a4e2346b73.zip tcl-7af465e6e0701eb6bd529ddc039d32a4e2346b73.tar.gz tcl-7af465e6e0701eb6bd529ddc039d32a4e2346b73.tar.bz2 |
* 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.
Diffstat (limited to 'generic/tclIOUtil.c')
-rw-r--r-- | generic/tclIOUtil.c | 26 |
1 files changed, 7 insertions, 19 deletions
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; |