diff options
author | vincentdarley <vincentdarley> | 2001-08-11 18:43:21 (GMT) |
---|---|---|
committer | vincentdarley <vincentdarley> | 2001-08-11 18:43:21 (GMT) |
commit | 2ae3f9e4b17879ee4cc7daba5a7cb109bef51a78 (patch) | |
tree | 161d118d7dfe1f3c40a3f01d82e371f371430537 | |
parent | e3e4bcea9c4105e94029baa9f8c5ddad79fdc692 (diff) | |
download | tcl-2ae3f9e4b17879ee4cc7daba5a7cb109bef51a78.zip tcl-2ae3f9e4b17879ee4cc7daba5a7cb109bef51a78.tar.gz tcl-2ae3f9e4b17879ee4cc7daba5a7cb109bef51a78.tar.bz2 |
vfs-related fixes
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tclFCmd.c | 19 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 3 |
3 files changed, 25 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2001-08-11 Vince Darley <vincentdarley@users.sourceforge.net> + + Variety of small issues introduced by the vfs code fixed: + * generic/tclIOUtil.c: uninitialised read. + * generic/tclFCmd.c: possible memory leak in file delete + with error condition. + 2001-08-10 Miguel Sofer <msofer@users.sourceforge.net> * generic/tclVar.c: diff --git a/generic/tclFCmd.c b/generic/tclFCmd.c index e0eccf9..8576ca8 100644 --- a/generic/tclFCmd.c +++ b/generic/tclFCmd.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclFCmd.c,v 1.8 2001/08/07 01:00:02 hobbs Exp $ + * RCS: @(#) $Id: tclFCmd.c,v 1.9 2001/08/11 18:43:21 vincentdarley Exp $ */ #include "tclInt.h" @@ -315,6 +315,7 @@ TclFileDeleteCmd(interp, objc, objv) { int i, force, result; Tcl_Obj *errfile; + Tcl_Obj *errorBuffer = NULL; i = FileForceOption(interp, objc - 2, objv + 2, &force); if (i < 0) { @@ -354,7 +355,10 @@ TclFileDeleteCmd(interp, objc, objv) result = TCL_ERROR; } } else if (S_ISDIR(statBuf.st_mode)) { - Tcl_Obj *errorBuffer = NULL; + /* + * We own a reference count on errorBuffer, if it was set + * as a result of this call. + */ result = Tcl_FSRemoveDirectory(objv[i], force, &errorBuffer); if (result != TCL_OK) { if ((force == 0) && (errno == EEXIST)) { @@ -379,7 +383,13 @@ TclFileDeleteCmd(interp, objc, objv) result = Tcl_FSDeleteFile(objv[i]); } - if (result == TCL_ERROR) { + if (result != TCL_OK) { + result = TCL_ERROR; + /* + * It is important that we break on error, otherwise we + * might end up owning reference counts on numerous + * errorBuffers. + */ break; } } @@ -396,6 +406,9 @@ TclFileDeleteCmd(interp, objc, objv) Tcl_GetString(errfile), "\": ", Tcl_PosixError(interp), (char *) NULL); } + if (errorBuffer != NULL) { + Tcl_DecrRefCount(errorBuffer); + } } done: return result; diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 50d1987..4dd0cfa 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.13 2001/08/02 22:16:44 hobbs Exp $ + * RCS: @(#) $Id: tclIOUtil.c,v 1.14 2001/08/11 18:43:21 vincentdarley Exp $ */ #include "tclInt.h" @@ -548,6 +548,7 @@ Tcl_FSRegister(clientData, fsPtr) newFilesystemPtr->clientData = clientData; newFilesystemPtr->fsPtr = fsPtr; + newFilesystemPtr->refCount = 0; /* * Is this lock and wait strictly speaking necessary? Since any |