Index: dlfcn.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/dlfcn.cc,v
retrieving revision 1.12
diff -u -p -r1.12 dlfcn.cc
--- dlfcn.cc	2001/03/26 01:16:11	1.12
+++ dlfcn.cc	2001/06/03 07:17:03
@@ -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;
