summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--generic/tclPathObj.c13
2 files changed, 14 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 8c75cef..846c746 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@
* generic/tclTest.c (SimpleMatchInDirectory): Corrected a refcount
imbalance that affected the filesystem-[147]* tests in the test
suite. Thanks to Don Porter for the patch. [Bug 1710707]
+ * generic/tclPathObj.c (Tcl_FSJoinPath, Tcl_FSGetNormalizedPath):
+ Corrected several memory leaks that caused refcount imbalances
+ resulting in memory leaks on Windows. Thanks to Joe Mistachkin
+ for the patch.
2007-05-01 Miguel Sofer <msofer@users.sf.net>
diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c
index 8744da8..b86c728 100644
--- a/generic/tclPathObj.c
+++ b/generic/tclPathObj.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclPathObj.c,v 1.62 2007/04/20 06:10:58 kennykb Exp $
+ * RCS: @(#) $Id: tclPathObj.c,v 1.63 2007/05/02 21:30:36 kennykb Exp $
*/
#include "tclInt.h"
@@ -843,7 +843,9 @@ Tcl_FSJoinPath(
int strEltLen;
int length;
char *ptr;
- Tcl_Obj *driveName = NULL;
+ Tcl_Obj *driveName;
+
+ driveName = NULL;
Tcl_ListObjIndex(NULL, listObj, i, &elt);
@@ -962,6 +964,8 @@ Tcl_FSJoinPath(
res = Tcl_NewStringObj(strElt, driveNameLength);
}
strElt += driveNameLength;
+ } else if (driveName != NULL) {
+ Tcl_DecrRefCount(driveName);
}
/*
@@ -1866,6 +1870,7 @@ Tcl_FSGetNormalizedPath(
Tcl_Obj *absolutePath = fsPathPtr->translatedPathPtr;
const char *path = TclGetString(absolutePath);
+ Tcl_IncrRefCount(absolutePath);
/*
* We have to be a little bit careful here to avoid infinite loops
@@ -1892,6 +1897,7 @@ Tcl_FSGetNormalizedPath(
return NULL;
}
+ Tcl_DecrRefCount(absolutePath);
absolutePath = Tcl_FSJoinToPath(useThisCwd, 1, &absolutePath);
Tcl_IncrRefCount(absolutePath);
@@ -1904,6 +1910,7 @@ Tcl_FSGetNormalizedPath(
* Only Windows has volume-relative paths.
*/
+ Tcl_DecrRefCount(absolutePath);
absolutePath = TclWinVolumeRelativeNormalize(interp,
path, &useThisCwd);
if (absolutePath == NULL) {
@@ -1953,9 +1960,9 @@ Tcl_FSGetNormalizedPath(
* of course store the cwd.
*/
- TclDecrRefCount(absolutePath);
fsPathPtr->cwdPtr = useThisCwd;
}
+ TclDecrRefCount(absolutePath);
}
return fsPathPtr->normPathPtr;