diff options
| author | pooryorick <com.digitalsmarties@pooryorick.com> | 2021-05-14 18:50:33 (GMT) |
|---|---|---|
| committer | pooryorick <com.digitalsmarties@pooryorick.com> | 2021-05-14 18:50:33 (GMT) |
| commit | 7987c596f2d8a52fa605d8c45e7f038a3872d70c (patch) | |
| tree | 3ccac5bf7ccb44067b48fdbcfb6ee2bbb2f99c7a /generic/tclLoad.c | |
| parent | 9fecbcc1066863fc2077df6d0ea5c06dad182af1 (diff) | |
| download | tcl-7987c596f2d8a52fa605d8c45e7f038a3872d70c.zip tcl-7987c596f2d8a52fa605d8c45e7f038a3872d70c.tar.gz tcl-7987c596f2d8a52fa605d8c45e7f038a3872d70c.tar.bz2 | |
Fix for issue [463b7a93be0a2ddd], Tcl_Unload, make gdb-test, segmentation fault
Diffstat (limited to 'generic/tclLoad.c')
| -rw-r--r-- | generic/tclLoad.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/generic/tclLoad.c b/generic/tclLoad.c index c9d1b31..430e1af 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -804,6 +804,31 @@ Tcl_UnloadObjCmd( goto done; } + + /* + * Remove this library from the interpreter's library cache. + */ + + ipFirstPtr = (InterpLibrary *)Tcl_GetAssocData(target, "tclLoad", NULL); + ipPtr = ipFirstPtr; + if (ipPtr->libraryPtr == libraryPtr) { + ipFirstPtr = ipFirstPtr->nextPtr; + } else { + InterpLibrary *ipPrevPtr; + + for (ipPrevPtr = ipPtr; ipPtr != NULL; + ipPrevPtr = ipPtr, ipPtr = ipPtr->nextPtr) { + if (ipPtr->libraryPtr == libraryPtr) { + ipPrevPtr->nextPtr = ipPtr->nextPtr; + break; + } + } + } + Tcl_SetAssocData(target, "tclLoad", LoadCleanupProc, + ipFirstPtr); + + + /* * The unload function executed fine. Examine the reference count to see * if we unload the DLL. @@ -870,27 +895,6 @@ Tcl_UnloadObjCmd( } } - /* - * Remove this library from the interpreter's library cache. - */ - - ipFirstPtr = (InterpLibrary *)Tcl_GetAssocData(target, "tclLoad", NULL); - ipPtr = ipFirstPtr; - if (ipPtr->libraryPtr == defaultPtr) { - ipFirstPtr = ipFirstPtr->nextPtr; - } else { - InterpLibrary *ipPrevPtr; - - for (ipPrevPtr = ipPtr; ipPtr != NULL; - ipPrevPtr = ipPtr, ipPtr = ipPtr->nextPtr) { - if (ipPtr->libraryPtr == defaultPtr) { - ipPrevPtr->nextPtr = ipPtr->nextPtr; - break; - } - } - } - Tcl_SetAssocData(target, "tclLoad", LoadCleanupProc, - ipFirstPtr); ckfree(defaultPtr->fileName); ckfree(defaultPtr->prefix); ckfree(defaultPtr); |
