FFI: Fix management of C library handles for default namespace.

This commit is contained in:
Mike Pall 2011-02-16 23:52:18 +01:00
parent 5fe7282d4c
commit 54b6054087

View File

@ -148,9 +148,13 @@ static void clib_unloadlib(CLibrary *cl)
{ {
if (cl->handle == CLIB_DEFHANDLE) { if (cl->handle == CLIB_DEFHANDLE) {
MSize i; MSize i;
for (i = 0; i < CLIB_HANDLE_MAX; i++) for (i = 0; i < CLIB_HANDLE_MAX; i++) {
if (clib_def_handle[i]) void *h = clib_def_handle[i];
FreeLibrary((HINSTANCE)clib_def_handle[i]); if (h) {
clib_def_handle[i] = NULL;
FreeLibrary((HINSTANCE)h);
}
}
} else if (!cl->handle) { } else if (!cl->handle) {
FreeLibrary((HINSTANCE)cl->handle); FreeLibrary((HINSTANCE)cl->handle);
} }