From 2ae3f9e4b17879ee4cc7daba5a7cb109bef51a78 Mon Sep 17 00:00:00 2001 From: vincentdarley Date: Sat, 11 Aug 2001 18:43:21 +0000 Subject: vfs-related fixes --- ChangeLog | 7 +++++++ generic/tclFCmd.c | 19 ++++++++++++++++--- generic/tclIOUtil.c | 3 ++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3cf4945..d8128f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2001-08-11 Vince Darley + + 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 * 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 -- cgit v0.12