summaryrefslogtreecommitdiffstats
path: root/generic/tclPathObj.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2007-05-02 21:30:35 (GMT)
committerKevin B Kenny <kennykb@acm.org>2007-05-02 21:30:35 (GMT)
commitee85deffc09d4eccdbdb33e8934c84a1114922b7 (patch)
tree19c4d5fe108a257d2bfe50a9590e179c5c2c45da /generic/tclPathObj.c
parent0a3cc905071ab12adf09fed2716e488adc24178f (diff)
downloadtcl-ee85deffc09d4eccdbdb33e8934c84a1114922b7.zip
tcl-ee85deffc09d4eccdbdb33e8934c84a1114922b7.tar.gz
tcl-ee85deffc09d4eccdbdb33e8934c84a1114922b7.tar.bz2
* 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.
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r--generic/tclPathObj.c13
1 files changed, 10 insertions, 3 deletions
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;