From 0167e195e962a427c247e3442abf6ea23fd36156 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 30 Sep 2020 15:37:34 +0200 Subject: [PATCH] ntdll: Fix handle/module confusion in Unix module loading. Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/loader.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 6890a08428b..f12cc518996 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -138,7 +138,7 @@ struct builtin_module struct file_id id; void *handle; void *module; - void *unix_module; + void *unix_handle; }; static struct list builtin_modules = LIST_INIT( builtin_modules ); @@ -149,7 +149,7 @@ static NTSTATUS add_builtin_module( void *module, void *handle, const struct sta if (!(builtin = malloc( sizeof(*builtin) ))) return STATUS_NO_MEMORY; builtin->handle = handle; builtin->module = module; - builtin->unix_module = NULL; + builtin->unix_handle = NULL; if (st) { builtin->id.dev = st->st_dev; @@ -1015,23 +1015,24 @@ static NTSTATUS dlopen_unix_dll( void *module, const char *name, void **unix_ent { if (builtin->module == module) { - if (builtin->unix_module == unix_module) /* already loaded */ + if (builtin->unix_handle == handle) /* already loaded */ { + *unix_entry = entry; status = STATUS_SUCCESS; goto done; } - if (builtin->unix_module) + if (builtin->unix_handle) { ERR( "module %p already has a Unix module that's not %s\n", module, debugstr_a(name) ); goto done; } if ((status = map_so_dll( nt, unix_module ))) goto done; if ((status = fixup_ntdll_imports( name, unix_module ))) goto done; - builtin->unix_module = handle; + builtin->unix_handle = handle; *unix_entry = entry; return STATUS_SUCCESS; } - else if (builtin->unix_module == unix_module) + else if (builtin->unix_handle == handle) { ERR( "%s already loaded for module %p\n", debugstr_a(name), module ); goto done; @@ -1339,7 +1340,7 @@ static NTSTATUS CDECL unload_builtin_dll( void *module ) if (builtin->module != module) continue; list_remove( &builtin->entry ); if (builtin->handle) dlclose( builtin->handle ); - if (builtin->unix_module) dlclose( builtin->unix_module ); + if (builtin->unix_handle) dlclose( builtin->unix_handle ); free( builtin ); return STATUS_SUCCESS; }