summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2022-03-22 00:46:17 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2022-03-22 00:46:17 (GMT)
commitf18c5e4638cd2246475e9fabb96410e8696bea81 (patch)
tree6920500d784396d13ee4a579191970d95e5401e6 /generic
parent04234b55afe944221c2b003572689431778c7c88 (diff)
downloadtcl-f18c5e4638cd2246475e9fabb96410e8696bea81.zip
tcl-f18c5e4638cd2246475e9fabb96410e8696bea81.tar.gz
tcl-f18c5e4638cd2246475e9fabb96410e8696bea81.tar.bz2
Fix [ac601b59bab7] by making only unloading a library from the process if it
has an Unload functions.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclLoad.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index 7ea1ebd..ee1862d 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -544,7 +544,7 @@ Tcl_LoadObjCmd(
*
* Tcl_UnloadObjCmd --
*
- * This function is invoked to process the "unload" Tcl command. See the
+ * Implements the the "unload" Tcl command. See the
* user documentation for details on what it does.
*
* Results:
@@ -764,6 +764,23 @@ Tcl_UnloadObjCmd(
return code;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * UnloadLibrary --
+ *
+ * Unloads a library from an interpreter, and also from the process if it
+ * is unloadable, i.e. if it provides an "unload" function.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * See description.
+ *
+ *----------------------------------------------------------------------
+ */
static int
UnloadLibrary(
Tcl_Interp *interp,
@@ -884,11 +901,9 @@ UnloadLibrary(
}
/*
- * The unload function executed fine. Examine the reference count to see
- * if we unload the DLL.
+ * The unload function was called succesfully.
*/
-
Tcl_MutexLock(&libraryMutex);
if (Tcl_IsSafe(target)) {
libraryPtr->safeInterpRefCount--;
@@ -917,7 +932,7 @@ UnloadLibrary(
code = TCL_OK;
if (libraryPtr->safeInterpRefCount <= 0 && libraryPtr->interpRefCount <= 0
- && !keepLibrary) {
+ && (unloadProc != NULL) && !keepLibrary) {
/*
* Unload the shared library from the application memory...
*/