From: Paul Gofman pgofman@codeweavers.com
--- dlls/kernel32/tests/module.c | 4 ++-- dlls/ntdll/loader.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index 23c99d0e084..f707522772f 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -1643,7 +1643,7 @@ static void test_tls_links(void) NTSTATUS status; HANDLE thread;
- todo_wine ok(!!teb->ThreadLocalStoragePointer, "got NULL.\n"); + ok(!!teb->ThreadLocalStoragePointer, "got NULL.\n");
test_tls_links_started = CreateEventW(NULL, FALSE, FALSE, NULL); test_tls_links_done = CreateEventW(NULL, FALSE, FALSE, NULL); @@ -1661,7 +1661,7 @@ static void test_tls_links(void) ResumeThread(thread); WaitForSingleObject(test_tls_links_started, INFINITE);
- todo_wine ok(!!thread_teb->ThreadLocalStoragePointer, "got NULL.\n"); + ok(!!thread_teb->ThreadLocalStoragePointer, "got NULL.\n"); todo_wine ok(!teb->TlsLinks.Flink, "got %p.\n", teb->TlsLinks.Flink); todo_wine ok(!teb->TlsLinks.Blink, "got %p.\n", teb->TlsLinks.Blink); todo_wine ok(!thread_teb->TlsLinks.Flink, "got %p.\n", thread_teb->TlsLinks.Flink); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 21378102ebd..ebdb08569c0 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -137,7 +137,7 @@ typedef struct _wine_modref BOOL system; } WINE_MODREF;
-static UINT tls_module_count; /* number of modules with TLS directory */ +static UINT tls_module_count = 32; /* number of modules with TLS directory */ static IMAGE_TLS_DIRECTORY *tls_dirs; /* array of TLS directories */ static LIST_ENTRY tls_links = { &tls_links, &tls_links };
@@ -1314,13 +1314,10 @@ static BOOL alloc_tls_slot( LDR_DATA_TABLE_ENTRY *mod )
if (i == tls_module_count) { - UINT new_count = max( 32, tls_module_count * 2 ); + UINT new_count = tls_module_count * 2;
- if (!tls_dirs) - new_ptr = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * sizeof(*tls_dirs) ); - else - new_ptr = RtlReAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, tls_dirs, - new_count * sizeof(*tls_dirs) ); + new_ptr = RtlReAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, tls_dirs, + new_count * sizeof(*tls_dirs) ); if (!new_ptr) return FALSE;
/* resize the pointer block in all running threads */ @@ -1568,8 +1565,6 @@ static NTSTATUS alloc_thread_tls(void) void **pointers; UINT i, size;
- if (!tls_module_count) return STATUS_SUCCESS; - if (!(pointers = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, tls_module_count * sizeof(*pointers) ))) return STATUS_NO_MEMORY; @@ -4342,6 +4337,9 @@ void loader_init( CONTEXT *context, void **entry ) RtlSetBits( peb->TlsBitmap, 0, NtCurrentTeb()->WowTebOffset ? WOW64_TLS_MAX_NUMBER : 1 ); RtlSetBits( peb->TlsBitmap, NTDLL_TLS_ERRNO, 1 );
+ if (!(tls_dirs = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, tls_module_count * sizeof(*tls_dirs) ))) + NtTerminateProcess( GetCurrentProcess(), STATUS_NO_MEMORY ); + init_user_process_params(); load_global_options(); version_init();