mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-04-20 16:50:37 -07:00
Don't go into infinite loop when unloading incorrectly loaded library.
This commit is contained in:
parent
378d21aab2
commit
fd710690ad
1 changed files with 12 additions and 9 deletions
21
src/c/load.d
21
src/c/load.d
|
|
@ -135,24 +135,28 @@ ecl_library_close(cl_object block) {
|
|||
cl_object libraries = cl_core.libraries;
|
||||
int i;
|
||||
|
||||
if (block->cblock.handle == NULL)
|
||||
return;
|
||||
if (block->cblock.name)
|
||||
filename = block->cblock.name->string.self;
|
||||
else
|
||||
filename = "<anonymous>";
|
||||
printf("\n;;; Freeing library %s\n", filename);
|
||||
|
||||
if (block->cblock.handle != NULL) {
|
||||
printf("\n;;; Freeing library %s\n", filename);
|
||||
#ifdef HAVE_DLFCN_H
|
||||
dlclose(block->cblock.handle);
|
||||
dlclose(block->cblock.handle);
|
||||
#endif
|
||||
#ifdef HAVE_MACH_O_DYLD_H
|
||||
NSUnLinkModule(block->cblock.handle, NSUNLINKMODULE_OPTION_NONE);
|
||||
NSUnLinkModule(block->cblock.handle, NSUNLINKMODULE_OPTION_NONE);
|
||||
#endif
|
||||
#if defined(mingw32) || defined(_MSC_VER)
|
||||
FreeLibrary(block->cblock.handle);
|
||||
FreeLibrary(block->cblock.handle);
|
||||
#endif
|
||||
if (block->cblock.self_destruct)
|
||||
}
|
||||
|
||||
if (block->cblock.self_destruct) {
|
||||
printf("\n;;; Removing file %s\n", filename);
|
||||
unlink(filename);
|
||||
}
|
||||
for (i = 0; i <= libraries->vector.fillp; i++) {
|
||||
if (libraries->vector.self.t[i] == block) {
|
||||
memcpy(libraries->vector.self.t+i,
|
||||
|
|
@ -169,9 +173,8 @@ void
|
|||
ecl_library_close_all(void)
|
||||
{
|
||||
int i;
|
||||
while ((i = cl_core.libraries->vector.fillp)) {
|
||||
while ((i = cl_core.libraries->vector.fillp))
|
||||
ecl_library_close(cl_core.libraries->vector.self.t[--i]);
|
||||
}
|
||||
}
|
||||
|
||||
cl_object
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue