Handle failures better (i.e. without crashing)

svn path=/trunk/; revision=12195
This commit is contained in:
Gé van Geldorp 2004-12-18 19:23:05 +00:00
parent 35d320bd71
commit e0c43e5c83
3 changed files with 15 additions and 3 deletions

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.36 2004/11/14 18:47:10 hbirr Exp $ /* $Id: process.c,v 1.37 2004/12/18 19:23:05 gvg Exp $
* *
* reactos/subsys/csrss/api/process.c * reactos/subsys/csrss/api/process.c
* *
@ -204,6 +204,7 @@ CSR_API(CsrCreateProcess)
Reply->Status = ApiReply.Status; Reply->Status = ApiReply.Status;
if (! NT_SUCCESS(Reply->Status)) if (! NT_SUCCESS(Reply->Status))
{ {
CsrFreeProcessData(Request->Data.CreateProcessRequest.NewProcessId);
return Reply->Status; return Reply->Status;
} }
Reply->Data.CreateProcessReply.InputHandle = ApiReply.Data.AllocConsoleReply.InputHandle; Reply->Data.CreateProcessReply.InputHandle = ApiReply.Data.AllocConsoleReply.InputHandle;

View file

@ -1,4 +1,4 @@
/* $Id: conio.c,v 1.17 2004/11/14 18:47:10 hbirr Exp $ /* $Id: conio.c,v 1.18 2004/12/18 19:23:05 gvg Exp $
* *
* reactos/subsys/csrss/win32csr/conio.c * reactos/subsys/csrss/win32csr/conio.c
* *
@ -219,6 +219,7 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
NewBuffer = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER)); NewBuffer = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
if (NULL == NewBuffer) if (NULL == NewBuffer)
{ {
ConioCleanupConsole(Console);
RtlFreeUnicodeString(&Console->Title); RtlFreeUnicodeString(&Console->Title);
RtlDeleteCriticalSection(&Console->Header.Lock); RtlDeleteCriticalSection(&Console->Header.Lock);
CloseHandle(Console->ActiveEvent); CloseHandle(Console->ActiveEvent);
@ -227,6 +228,7 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
Status = CsrInitConsoleScreenBuffer(Console, NewBuffer); Status = CsrInitConsoleScreenBuffer(Console, NewBuffer);
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
{ {
ConioCleanupConsole(Console);
RtlFreeUnicodeString(&Console->Title); RtlFreeUnicodeString(&Console->Title);
RtlDeleteCriticalSection(&Console->Header.Lock); RtlDeleteCriticalSection(&Console->Header.Lock);
CloseHandle(Console->ActiveEvent); CloseHandle(Console->ActiveEvent);

View file

@ -1,4 +1,4 @@
/* $Id: guiconsole.c,v 1.24 2004/12/05 01:13:29 navaraf Exp $ /* $Id: guiconsole.c,v 1.25 2004/12/18 19:23:05 gvg Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -793,6 +793,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
HWND NewWindow; HWND NewWindow;
LONG WindowCount; LONG WindowCount;
MSG Msg;
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam; PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
switch(msg) switch(msg)
@ -820,6 +821,14 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
} }
return (LRESULT) NewWindow; return (LRESULT) NewWindow;
case PM_DESTROY_CONSOLE: case PM_DESTROY_CONSOLE:
/* Window creation is done using a PostMessage(), so it's possible that the
* window that we want to destroy doesn't exist yet. So first empty the message
* queue */
while(PeekMessageW(&Msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessageW(&Msg);
}
DestroyWindow(Console->hWindow); DestroyWindow(Console->hWindow);
Console->hWindow = NULL; Console->hWindow = NULL;
WindowCount = GetWindowLongW(hWnd, GWL_USERDATA); WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);