diff options
author | Kevin B Kenny <kennykb@acm.org> | 2007-05-02 21:30:35 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2007-05-02 21:30:35 (GMT) |
commit | ee85deffc09d4eccdbdb33e8934c84a1114922b7 (patch) | |
tree | 19c4d5fe108a257d2bfe50a9590e179c5c2c45da | |
parent | 0a3cc905071ab12adf09fed2716e488adc24178f (diff) | |
download | tcl-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.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | generic/tclPathObj.c | 13 |
2 files changed, 14 insertions, 3 deletions
@@ -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; |