Index: generic/tclZipfs.c
==================================================================
--- generic/tclZipfs.c
+++ generic/tclZipfs.c
@@ -1880,11 +1880,10 @@
 	Unlock();
 	ZipFSCloseArchive(interp, zf);
 	Tcl_Free(zf);
 	return TCL_ERROR;
     }
-    Unlock();
 
     /*
      * Convert to a real archive descriptor.
      */
 
@@ -2096,12 +2095,12 @@
     nextent:
 	q += pathlen + comlen + extra + ZIP_CENTRAL_HEADER_LEN;
     }
     Tcl_DStringFree(&fpBuf);
     Tcl_DStringFree(&ds);
+    Unlock();
     Tcl_FSMountsChanged(NULL);
-    Unlock();
     return TCL_OK;
 }
 
 /*
  *-------------------------------------------------------------------------
@@ -4334,10 +4333,11 @@
 
     if (info->isEncrypted) {
 	info->isEncrypted = 0;
 	memset(info->keys, 0, sizeof(info->keys));
     }
+    WriteLock();
     if (info->isWriting) {
 	/*
 	 * Copy channel data back into original file in archive.
 	 * TODO - there seems to be no locking here to protect access from
 	 * multiple threads. The channel (info) may be thread specific (?)
@@ -4368,11 +4368,10 @@
 	z->isDirectory = 0;
 	z->isEncrypted = 0;
 	z->offset = 0;
 	z->crc32 = 0;
     }
-    WriteLock();
     info->zipFilePtr->numOpen--;
     Unlock();
     if (info->ubufToFree) {
 	assert(info->ubuf);
 	Tcl_Free(info->ubufToFree);

