kernel32: Clear the module handle on failure in GetModuleHandleEx.

This commit is contained in:
Hans Leidekker 2012-04-05 11:16:08 +02:00 committed by Alexandre Julliard
parent e8a95bf683
commit f96c7278e7
2 changed files with 7 additions and 5 deletions

View File

@ -548,7 +548,9 @@ BOOL WINAPI GetModuleHandleExW( DWORD flags, LPCWSTR name, HMODULE *module )
!(flags & GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT))
LdrUnlockLoaderLock( 0, magic );
*module = ret;
if (status == STATUS_SUCCESS) *module = ret;
else *module = NULL;
return (status == STATUS_SUCCESS);
}

View File

@ -540,7 +540,7 @@ static void testGetModuleHandleEx(void)
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
todo_wine ok( mod == NULL, "got %p\n", mod );
ok( mod == NULL, "got %p\n", mod );
SetLastError( 0xdeadbeef );
ret = pGetModuleHandleExW( 0, NULL, NULL );
@ -567,7 +567,7 @@ static void testGetModuleHandleEx(void)
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
todo_wine ok( mod == NULL, "got %p\n", mod );
ok( mod == NULL, "got %p\n", mod );
SetLastError( 0xdeadbeef );
ret = pGetModuleHandleExA( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
@ -593,7 +593,7 @@ static void testGetModuleHandleEx(void)
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
todo_wine ok( mod == NULL, "got %p\n", mod );
ok( mod == NULL, "got %p\n", mod );
SetLastError( 0xdeadbeef );
ret = pGetModuleHandleExW( GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, NULL, NULL );
@ -619,7 +619,7 @@ static void testGetModuleHandleEx(void)
error = GetLastError();
ok( !ret, "unexpected success\n" );
ok( error == ERROR_MOD_NOT_FOUND, "got %u\n", error );
todo_wine ok( mod == NULL, "got %p\n", mod );
ok( mod == NULL, "got %p\n", mod );
mod_kernel32 = LoadLibraryA( "kernel32" );