From 3e9935c9d0351de3a1b1da3f2c9dbb01e78799c7 Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Wed, 25 Apr 2007 19:09:03 +0000 Subject: * 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] --- ChangeLog | 7 +++++++ generic/tclIOUtil.c | 9 ++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23169c6..883c80d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-04-25 Kevin B. Kenny + + * generic/tclIOUtil.c (Tcl_FSChdir): Changed the memory management + so 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] + 2007-04-25 Don Porter * generic/tclCompExpr.c (ParseExpr): Revised to be sure that 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); } -- cgit v0.12