From 3255097117e119598ccd07bdb3efebe34f7a528c Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 12 Sep 1999 20:49:06 +0000 Subject: [PATCH] Stack is freed on failure. svn path=/trunk/; revision=662 --- reactos/lib/ntdll/rtl/thread.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/reactos/lib/ntdll/rtl/thread.c b/reactos/lib/ntdll/rtl/thread.c index ba3e0ad7632..b39d82c9951 100644 --- a/reactos/lib/ntdll/rtl/thread.c +++ b/reactos/lib/ntdll/rtl/thread.c @@ -42,6 +42,7 @@ RtlCreateUserThread(HANDLE ProcessHandle, ULONG ReservedSize; ULONG CommitSize; ULONG GuardSize; + ULONG RegionSize; NTSTATUS Status; /* initialize initial teb */ @@ -57,6 +58,8 @@ RtlCreateUserThread(HANDLE ProcessHandle, GuardSize = PAGESIZE; + RegionSize = 0; + /* Reserve stack */ InitialTeb.StackReserved = NULL; Status = NtAllocateVirtualMemory(ProcessHandle, @@ -93,6 +96,12 @@ RtlCreateUserThread(HANDLE ProcessHandle, if (!NT_SUCCESS(Status)) { + /* release the stack space */ + NtFreeVirtualMemory(ProcessHandle, + InitialTeb.StackReserved, + &RegionSize, + MEM_RELEASE); + DPRINT("Error committing stack page!\n"); return Status; } @@ -110,6 +119,12 @@ RtlCreateUserThread(HANDLE ProcessHandle, if (!NT_SUCCESS(Status)) { + /* release the stack space */ + NtFreeVirtualMemory(ProcessHandle, + InitialTeb.StackReserved, + &RegionSize, + MEM_RELEASE); + DPRINT("Error committing guard page!\n"); return Status; } @@ -144,14 +159,13 @@ RtlCreateUserThread(HANDLE ProcessHandle, if (!NT_SUCCESS(Status)) { - ULONG RegionSize = 0; - /* release the stack space */ NtFreeVirtualMemory(ProcessHandle, InitialTeb.StackReserved, &RegionSize, MEM_RELEASE); + DPRINT("Error creating thread!\n"); return Status; } @@ -223,4 +237,13 @@ RtlInitializeContext(HANDLE ProcessHandle, return STATUS_SUCCESS; } + +NTSTATUS STDCALL +RtlDestroyUserThreadStack(param1, param2) +{ + + + +} + /* EOF */