AttrSet bug fix
authorVince Darley <vincentdarley@sourceforge.net>
Mon, 13 Sep 2004 14:32:06 +0000 (14:32 +0000)
committerVince Darley <vincentdarley@sourceforge.net>
Mon, 13 Sep 2004 14:32:06 +0000 (14:32 +0000)
ChangeLog
generic/vfs.c

index c654415d247397093bba5b4788942aeac2056bd7..f880ff3107de2d49af708a969db1668265808bc0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-13  Vince Darley <vincentdarley@sourceforge.net>
+
+       * 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  <andreask@activestate.com>
 
        * library/zipvfs.tcl (Data): Fixed [SF Tclvfs Bug 1003591]. This
index 618edb7da2ddeecbc427badf693bca4db0f6eb63..d33806c10ebd395484d335311d2616fc706668c8 100644 (file)
@@ -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;
 }