ntdll: Fix the libdl refcount when loading the same builtin twice.
authorAlexandre Julliard <julliard@winehq.org>
Wed, 20 Dec 2006 14:54:27 +0000 (15:54 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 20 Dec 2006 14:54:27 +0000 (15:54 +0100)
dlls/kernel32/tests/module.c
dlls/ntdll/loader.c

index 340d646..d3f64a8 100644 (file)
@@ -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");
 }
index 23c6e3b..98b83b7 100644 (file)
@@ -1553,7 +1553,11 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
         }
     }
 
-    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( LPCWSTR load_path, LPCWSTR path, HANDLE file,
                 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++;
     }