Stack is freed on failure.

svn path=/trunk/; revision=662
This commit is contained in:
Eric Kohl 1999-09-12 20:49:06 +00:00
parent 40f81ce970
commit 3255097117

View file

@ -42,6 +42,7 @@ RtlCreateUserThread(HANDLE ProcessHandle,
ULONG ReservedSize; ULONG ReservedSize;
ULONG CommitSize; ULONG CommitSize;
ULONG GuardSize; ULONG GuardSize;
ULONG RegionSize;
NTSTATUS Status; NTSTATUS Status;
/* initialize initial teb */ /* initialize initial teb */
@ -57,6 +58,8 @@ RtlCreateUserThread(HANDLE ProcessHandle,
GuardSize = PAGESIZE; GuardSize = PAGESIZE;
RegionSize = 0;
/* Reserve stack */ /* Reserve stack */
InitialTeb.StackReserved = NULL; InitialTeb.StackReserved = NULL;
Status = NtAllocateVirtualMemory(ProcessHandle, Status = NtAllocateVirtualMemory(ProcessHandle,
@ -93,6 +96,12 @@ RtlCreateUserThread(HANDLE ProcessHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* release the stack space */
NtFreeVirtualMemory(ProcessHandle,
InitialTeb.StackReserved,
&RegionSize,
MEM_RELEASE);
DPRINT("Error committing stack page!\n"); DPRINT("Error committing stack page!\n");
return Status; return Status;
} }
@ -110,6 +119,12 @@ RtlCreateUserThread(HANDLE ProcessHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* release the stack space */
NtFreeVirtualMemory(ProcessHandle,
InitialTeb.StackReserved,
&RegionSize,
MEM_RELEASE);
DPRINT("Error committing guard page!\n"); DPRINT("Error committing guard page!\n");
return Status; return Status;
} }
@ -144,14 +159,13 @@ RtlCreateUserThread(HANDLE ProcessHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
ULONG RegionSize = 0;
/* release the stack space */ /* release the stack space */
NtFreeVirtualMemory(ProcessHandle, NtFreeVirtualMemory(ProcessHandle,
InitialTeb.StackReserved, InitialTeb.StackReserved,
&RegionSize, &RegionSize,
MEM_RELEASE); MEM_RELEASE);
DPRINT("Error creating thread!\n");
return Status; return Status;
} }
@ -223,4 +237,13 @@ RtlInitializeContext(HANDLE ProcessHandle,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS STDCALL
RtlDestroyUserThreadStack(param1, param2)
{
}
/* EOF */ /* EOF */