aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/dlfcn.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/dlfcn.cc')
-rw-r--r--winsup/cygwin/dlfcn.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/winsup/cygwin/dlfcn.cc b/winsup/cygwin/dlfcn.cc
index d1aef52..39add1d 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;