From 3b735be29deae48aea3b30d84fda040501600ce9 Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Sat, 2 Dec 2023 16:30:22 +0100 Subject: Fix dlclose() for dlopen(NULL, ...) dlopen(NULL, ...) does not call LoadLibrary(), so do not call FreeLibrary() in dlclose() for this case. --- src/dlfcn.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/dlfcn.c b/src/dlfcn.c index cb9f9bb..be6e01f 100644 --- a/src/dlfcn.c +++ b/src/dlfcn.c @@ -466,6 +466,10 @@ int dlclose( void *handle ) error_occurred = FALSE; + /* dlopen(NULL, ...) does not call LoadLibrary(), so do not call FreeLibrary(). */ + if( hModule == GetModuleHandle( NULL ) ) + return 0; + ret = FreeLibrary( hModule ); /* If the object was loaded with RTLD_LOCAL, remove it from list of local -- cgit v1.2.3-55-g6feb