diff options
author | kennykb <kennykb@noemail.net> | 2007-05-02 21:30:34 (GMT) |
---|---|---|
committer | kennykb <kennykb@noemail.net> | 2007-05-02 21:30:34 (GMT) |
commit | 3bbd07221baea9acbde2f65a2c9036030cc0eb28 (patch) | |
tree | 19c4d5fe108a257d2bfe50a9590e179c5c2c45da /generic/tclPathObj.c | |
parent | 209bfd712b2b1f289729a31d06b48009a6330ed2 (diff) | |
download | tcl-3bbd07221baea9acbde2f65a2c9036030cc0eb28.zip tcl-3bbd07221baea9acbde2f65a2c9036030cc0eb28.tar.gz tcl-3bbd07221baea9acbde2f65a2c9036030cc0eb28.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.
FossilOrigin-Name: d9bda6ffc817a1b8159ce6cfffc19c590b6deb0c
Diffstat (limited to 'generic/tclPathObj.c')
-rw-r--r-- | generic/tclPathObj.c | 13 |
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; |