Index: dll/win32/kernel32/client/fiber.c =================================================================== --- dll/win32/kernel32/client/fiber.c (révision 58535) +++ dll/win32/kernel32/client/fiber.c (copie de travail) @@ -210,9 +210,9 @@ /* Free the fiber */ RtlFreeHeap(GetProcessHeap(), 0, Fiber); - /* Free the activation context */ - DPRINT1("Leaking activation stack because nobody implemented free"); - //RtlFreeActivationContextStack(&ActivationContextStack); + /* Free the activation context stack */ + // DPRINT1("Leaking activation stack because nobody implemented free"); + RtlFreeActivationContextStack(&ActivationContextStack); /* Failure */ BaseSetLastNTError(Status); @@ -271,9 +271,9 @@ /* Get rid of FLS */ if (Fiber->FlsData) BaseRundownFls(Fiber->FlsData); - /* Get rid of the activation stack */ - DPRINT1("Leaking activation stack because nobody implemented free"); - //RtlFreeActivationContextStack(Fiber->ActivationContextStack); + /* Get rid of the activation context stack */ + // DPRINT1("Leaking activation stack because nobody implemented free"); + RtlFreeActivationContextStack(Fiber->ActivationContextStack); /* Free the fiber data */ RtlFreeHeap(GetProcessHeap(), 0, lpFiber); Index: dll/win32/kernel32/client/thread.c =================================================================== --- dll/win32/kernel32/client/thread.c (révision 58535) +++ dll/win32/kernel32/client/thread.c (copie de travail) @@ -191,7 +191,7 @@ dwCreationFlags & STACK_SIZE_PARAM_IS_A_RESERVATION ? dwStackSize : 0, &InitialTeb); - if(!NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { BaseSetLastNTError(Status); return NULL; @@ -241,7 +241,7 @@ ERROR_DBGBREAK("SXS: %s - Failing thread create because " "NtQueryInformationThread() failed with status %08lx\n", __FUNCTION__, Status); - return NULL; + goto Quit; } /* Allocate the Activation Context Stack */ @@ -252,7 +252,7 @@ ERROR_DBGBREAK("SXS: %s - Failing thread create because " "RtlAllocateActivationContextStack() failed with status %08lx\n", __FUNCTION__, Status); - return NULL; + goto Quit; } /* Save it */ @@ -274,7 +274,13 @@ ERROR_DBGBREAK("SXS: %s - Failing thread create because " "RtlQueryInformationActivationContext() failed with status %08lx\n", __FUNCTION__, Status); - return NULL; + + /* Free the activation context stack */ + // RtlFreeThreadActivationContextStack(); + RtlFreeActivationContextStack(Teb->ActivationContextStackPointer); + Teb->ActivationContextStackPointer = NULL; + + goto Quit; } /* Does it need to be activated? */ @@ -291,7 +297,13 @@ ERROR_DBGBREAK("SXS: %s - Failing thread create because " "RtlActivateActivationContextEx() failed with status %08lx\n", __FUNCTION__, Status); - return NULL; + + /* Free the activation context stack */ + // RtlFreeThreadActivationContextStack(); + RtlFreeActivationContextStack(Teb->ActivationContextStackPointer); + Teb->ActivationContextStackPointer = NULL; + + goto Quit; } } } @@ -299,9 +311,7 @@ /* Notify CSR */ if (!BaseRunningInServerProcess) { - /* Notify CSR */ Status = BasepNotifyCsrOfThread(hThread, &ClientId); - ASSERT(NT_SUCCESS(Status)); } else { @@ -317,19 +327,34 @@ { /* Call it instead of going through LPC */ Status = CsrCreateRemoteThread(hThread, &ClientId); - ASSERT(NT_SUCCESS(Status)); } } } - /* Success */ - if (lpThreadId) *lpThreadId = HandleToUlong(ClientId.UniqueThread); +Quit: + if (NT_SUCCESS(Status)) + { + /* Success */ + if (lpThreadId) *lpThreadId = HandleToUlong(ClientId.UniqueThread); - /* Resume it if asked */ - if (!(dwCreationFlags & CREATE_SUSPENDED)) NtResumeThread(hThread, &Dummy); + /* Resume it if asked */ + if (!(dwCreationFlags & CREATE_SUSPENDED)) NtResumeThread(hThread, &Dummy); - /* Return handle to thread */ - return hThread; + /* Return handle to thread */ + return hThread; + } + else + { + /* Fail */ + Status = STATUS_NO_MEMORY; + + BaseFreeThreadStack(hProcess, &InitialTeb); + NtTerminateThread(hThread, Status); + NtClose(hThread); + BaseSetLastNTError(Status); + + return NULL; + } } /*