From 5860f82135ef9563e1dd60b1c00daeedb1767c7d Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 25 Aug 2025 16:42:09 +0000 Subject: amend to [0433b67adc] (ticket [87b69745be]): don't return with OK (swallow the error) if encoding cannot be loaded, and current system encoding is NULL for whatever reason --- generic/tclEncoding.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 43566ce..cbd2dc0 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -996,15 +996,15 @@ Tcl_SetSystemEncoding( ((Encoding *)encoding)->refCount += 1; } else { encoding = Tcl_GetEncoding(interp, name); + if (encoding == NULL) { + Tcl_MutexUnlock(&encodingMutex); + return TCL_ERROR; + } if (encoding == systemEncoding) { FreeEncoding(encoding); Tcl_MutexUnlock(&encodingMutex); return TCL_OK; } - if (encoding == NULL) { - Tcl_MutexUnlock(&encodingMutex); - return TCL_ERROR; - } } assert(encoding != systemEncoding); -- cgit v0.12 From 4478afff2aa58272cd2300927f054c710c4cc1c1 Mon Sep 17 00:00:00 2001 From: sebres Date: Mon, 25 Aug 2025 22:55:02 +0000 Subject: fixes too earlier search for tcl-library (TclZipfsLocateTclLibrary shall be invoked after zipfs mount). --- generic/tclZipfs.c | 52 +++++++++++++++++----------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index bb27ae9..cd17306 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -6411,7 +6411,7 @@ ZipfsAppHookFindTclInit( if (zipfs_literal_tcl_library) { return TCL_ERROR; } - if (TclZipfs_Mount(NULL, archive, ZIPFS_ZIP_MOUNT, NULL)) { + if (TclZipfs_Mount(NULL, archive, ZIPFS_ZIP_MOUNT, NULL) != TCL_OK) { /* Either the file doesn't exist or it is not a zip archive */ return TCL_ERROR; } @@ -6553,17 +6553,19 @@ TclZipfs_AppHook( archive = Tcl_GetNameOfExecutable(); TclZipfs_Init(NULL); /* - * Look for init.tcl in one of the locations mounted later in this - * function. Errors ignored as other locations may be available. + * After mount, we'll look for init.tcl in one of the mounted locations. + * Thereby errors ignored as other locations may be available. */ - if (TclZipfsLocateTclLibrary() == TCL_OK) { - (void) TclZipfsInitEncodingDirs(); - } - if (!TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL)) { - int found; + if (TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL) == TCL_OK) { Tcl_Obj *vfsInitScript; + if (!zipfs_literal_tcl_library) { + if (TclZipfsLocateTclLibrary() == TCL_OK) { + (void) TclZipfsInitEncodingDirs(); + } + } + TclNewLiteralStringObj(vfsInitScript, ZIPFS_APP_MOUNT "/main.tcl"); Tcl_IncrRefCount(vfsInitScript); if (Tcl_FSAccess(vfsInitScript, F_OK) == 0) { @@ -6576,21 +6578,6 @@ TclZipfs_AppHook( Tcl_DecrRefCount(vfsInitScript); } - /* - * Set Tcl Encodings - */ - - if (!zipfs_literal_tcl_library) { - TclNewLiteralStringObj(vfsInitScript, - ZIPFS_APP_MOUNT "/tcl_library/init.tcl"); - Tcl_IncrRefCount(vfsInitScript); - found = Tcl_FSAccess(vfsInitScript, F_OK); - Tcl_DecrRefCount(vfsInitScript); - if (found == TCL_OK) { - zipfs_literal_tcl_library = ZIPFS_APP_MOUNT "/tcl_library"; - return result; - } - } #ifdef SUPPORT_BUILTIN_ZIP_INSTALL } else if (*argcPtr > 1) { /* @@ -6622,10 +6609,15 @@ TclZipfs_AppHook( Tcl_SetStartupScript(vfsInitScript, NULL); } return result; - } else if (!TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL)) { - int found; + } else if (TclZipfs_Mount(NULL, archive, ZIPFS_APP_MOUNT, NULL) == TCL_OK) { Tcl_Obj *vfsInitScript; + if (!zipfs_literal_tcl_library) { + if (TclZipfsLocateTclLibrary() == TCL_OK) { + (void) TclZipfsInitEncodingDirs(); + } + } + TclNewLiteralStringObj(vfsInitScript, ZIPFS_APP_MOUNT "/main.tcl"); Tcl_IncrRefCount(vfsInitScript); if (Tcl_FSAccess(vfsInitScript, F_OK) == 0) { @@ -6637,16 +6629,6 @@ TclZipfs_AppHook( } else { Tcl_DecrRefCount(vfsInitScript); } - /* Set Tcl Encodings */ - TclNewLiteralStringObj(vfsInitScript, - ZIPFS_APP_MOUNT "/tcl_library/init.tcl"); - Tcl_IncrRefCount(vfsInitScript); - found = Tcl_FSAccess(vfsInitScript, F_OK); - Tcl_DecrRefCount(vfsInitScript); - if (found == TCL_OK) { - zipfs_literal_tcl_library = ZIPFS_APP_MOUNT "/tcl_library"; - return result; - } } #ifdef _WIN32 Tcl_DStringFree(&ds); -- cgit v0.12