summaryrefslogtreecommitdiffstats
path: root/generic/tclIOUtil.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2007-04-25 19:09:03 (GMT)
committerKevin B Kenny <kennykb@acm.org>2007-04-25 19:09:03 (GMT)
commit3e9935c9d0351de3a1b1da3f2c9dbb01e78799c7 (patch)
treefc7aa243eab8a38f2201fac2a7b4e093d1ecb89d /generic/tclIOUtil.c
parentbc808f183f4c2b6328fe0d9d44396e1147795f84 (diff)
downloadtcl-3e9935c9d0351de3a1b1da3f2c9dbb01e78799c7.zip
tcl-3e9935c9d0351de3a1b1da3f2c9dbb01e78799c7.tar.gz
tcl-3e9935c9d0351de3a1b1da3f2c9dbb01e78799c7.tar.bz2
* generic/tclIOUtil.c (Tcl_FSChdir): Changed the memory management
to that the path returned from Tcl_FSGetNativePath is not duplicated before being stored as the current directory, to avoid a memory leak. [Bug 1705778, leak K01 among other manifestations]
Diffstat (limited to 'generic/tclIOUtil.c')
-rw-r--r--generic/tclIOUtil.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index a2b0555..5725e45 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.144 2007/04/20 06:10:57 kennykb Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.145 2007/04/25 19:09:03 kennykb Exp $
*/
#include "tclInt.h"
@@ -2971,14 +2971,17 @@ Tcl_FSChdir(
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&tclFsDataKey);
ClientData cd;
+ ClientData oldcd = tsdPtr->cwdClientData;
/*
* Assumption we are using a filesystem version 2.
*/
TclFSGetCwdProc2 *proc2 = (TclFSGetCwdProc2*)fsPtr->getCwdProc;
- cd = (*proc2)(tsdPtr->cwdClientData);
- FsUpdateCwd(normDirName, TclNativeDupInternalRep(cd));
+ cd = (*proc2)(oldcd);
+ if (cd != oldcd) {
+ FsUpdateCwd(normDirName, cd);
+ }
} else {
FsUpdateCwd(normDirName, NULL);
}