Alexandre Julliard : ntdll: Fix the libdl refcount when loading the same builtin twice.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Dec 20 08:55:04 CST 2006


Module: wine
Branch: master
Commit: 2a1dc157903453e39606e72b27e9a8ae2d1c6dca
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2a1dc157903453e39606e72b27e9a8ae2d1c6dca

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Dec 20 15:54:27 2006 +0100

ntdll: Fix the libdl refcount when loading the same builtin twice.

---

 dlls/kernel32/tests/module.c |    2 +-
 dlls/ntdll/loader.c          |    7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c
index 340d646..d3f64a8 100644
--- a/dlls/kernel32/tests/module.c
+++ b/dlls/kernel32/tests/module.c
@@ -179,7 +179,7 @@ static void testNestedLoadLibraryA(void)
 
     /* Try to load the dll again, if refcounting is ok, this should work */
     hModule1 = LoadLibraryA(path1);
-    todo_wine ok(hModule1 != NULL, "LoadLibrary(%s) failed\n", path1);
+    ok(hModule1 != NULL, "LoadLibrary(%s) failed\n", path1);
     if (hModule1 != NULL)
         ok(FreeLibrary(hModule1), "FreeLibrary() failed\n");
 }
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 23c6e3b..98b83b7 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1553,7 +1553,11 @@ static NTSTATUS load_builtin_dll( LPCWST
         }
     }
 
-    if (info.status != STATUS_SUCCESS) return info.status;
+    if (info.status != STATUS_SUCCESS)
+    {
+        wine_dll_unload( handle );
+        return info.status;
+    }
 
     if (!info.wm)
     {
@@ -1574,6 +1578,7 @@ static NTSTATUS load_builtin_dll( LPCWST
                 break;
             }
         }
+        wine_dll_unload( handle );  /* release the libdl refcount */
         if (!info.wm) return STATUS_INVALID_IMAGE_FORMAT;
         if (info.wm->ldr.LoadCount != -1) info.wm->ldr.LoadCount++;
     }




More information about the wine-cvs mailing list