From: Vince Darley Date: Mon, 13 Sep 2004 14:32:06 +0000 (+0000) Subject: AttrSet bug fix X-Git-Tag: vfs-1-4~82 X-Git-Url: https://privyetmir.co.uk/gitweb.cgi?a=commitdiff_plain;h=42ab8bbe513c67871affc2db54c16917808ecc9f;p=tclvfs AttrSet bug fix --- diff --git a/ChangeLog b/ChangeLog index c654415..f880ff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-09-13 Vince Darley + + * generic/vfs.c: fix to crash if TclVfsAttr(Set|Get) are called + with a NULL interp for error reporting. [Bug 1022202] + 2004-08-05 Andreas Kupries * library/zipvfs.tcl (Data): Fixed [SF Tclvfs Bug 1003591]. This diff --git a/generic/vfs.c b/generic/vfs.c index 618edb7..d33806c 100644 --- a/generic/vfs.c +++ b/generic/vfs.c @@ -1713,14 +1713,20 @@ VfsFileAttrsGet(cmdInterp, index, pathPtr, objPtrRef) */ } else { /* Leave error message in correct interp */ - Tcl_SetObjResult(cmdInterp, *objPtrRef); + if (cmdInterp != NULL) { + Tcl_SetObjResult(cmdInterp, *objPtrRef); + } else { + Tcl_DecrRefCount(*objPtrRef); + } *objPtrRef = NULL; } } else { - Tcl_ResetResult(cmdInterp); - Tcl_AppendResult(cmdInterp, "couldn't read attributes for \"", - Tcl_GetString(pathPtr), "\": ", - Tcl_PosixError(cmdInterp), (char *) NULL); + if (cmdInterp != NULL) { + Tcl_ResetResult(cmdInterp); + Tcl_AppendResult(cmdInterp, "couldn't read attributes for \"", + Tcl_GetString(pathPtr), "\": ", + Tcl_PosixError(cmdInterp), (char *) NULL); + } } return returnVal; @@ -1757,19 +1763,22 @@ VfsFileAttrsSet(cmdInterp, index, pathPtr, objPtr) Tcl_RestoreResult(interp, &savedResult); Tcl_DecrRefCount(mountCmd); - if (returnVal == -1) { - Tcl_ResetResult(cmdInterp); - Tcl_AppendResult(cmdInterp, "couldn't set attributes for \"", - Tcl_GetString(pathPtr), "\": ", - Tcl_PosixError(cmdInterp), (char *) NULL); + if (cmdInterp != NULL) { + if (returnVal == -1) { + Tcl_ResetResult(cmdInterp); + Tcl_AppendResult(cmdInterp, "couldn't set attributes for \"", + Tcl_GetString(pathPtr), "\": ", + Tcl_PosixError(cmdInterp), (char *) NULL); + } else if (errorPtr != NULL) { + /* + * Leave error message in correct interp, errorPtr was + * duplicated above, in case of threading issues. + */ + Tcl_SetObjResult(cmdInterp, errorPtr); + } } else if (errorPtr != NULL) { - /* - * Leave error message in correct interp, errorPtr was - * duplicated above, in case of threading issues. - */ - Tcl_SetObjResult(cmdInterp, errorPtr); + Tcl_DecrRefCount(errorPtr); } - return returnVal; }