From aa7a61121e3de86aba370055852a75caca041c97 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 3 Jun 2001 14:13:12 +0000 Subject: * dlfcn.cc (dlclose): Do not call FreeLibrary if the symbol to close was obtained by dlopen(NULL,...). --- winsup/cygwin/dlfcn.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'winsup/cygwin/dlfcn.cc') diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc index d1aef528a..39add1dbc 100644 --- a/winsup/cygwin/dlfcn.cc +++ b/winsup/cygwin/dlfcn.cc @@ -129,10 +129,12 @@ dlclose (void *handle) SetResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose"); int ret = -1; - if (FreeLibrary ((HMODULE) handle)) + void *temphandle = (void *) GetModuleHandle (NULL); + if (temphandle == handle || FreeLibrary ((HMODULE) handle)) ret = 0; if (ret) set_dl_error ("dlclose"); + CloseHandle ((HMODULE) temphandle); ReleaseResourceLock(LOCK_DLL_LIST,READ_LOCK|WRITE_LOCK," dlclose"); return ret; -- cgit v1.2.3