Tcl Source Code

Artifact [8c002ae7b8]
Login

Artifact 8c002ae7b802838e264ded9b54ae2d7c67aa17296cae7b57d0b019429ab9aa96:

Attachment "49456a66de.diff" to ticket [48861782a9] added by chw 2023-10-02 19:01:09.
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);