Handle failures better (i.e. without crashing)
authorGé van Geldorp <ge@gse.nl>
Sat, 18 Dec 2004 19:23:05 +0000 (19:23 +0000)
committerGé van Geldorp <ge@gse.nl>
Sat, 18 Dec 2004 19:23:05 +0000 (19:23 +0000)
svn path=/trunk/; revision=12195

reactos/subsys/csrss/api/process.c
reactos/subsys/csrss/win32csr/conio.c
reactos/subsys/csrss/win32csr/guiconsole.c

index 75d6dc1..4d13e8d 100644 (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
  *
@@ -204,6 +204,7 @@ CSR_API(CsrCreateProcess)
         Reply->Status = ApiReply.Status;
         if (! NT_SUCCESS(Reply->Status))
           {
+            CsrFreeProcessData(Request->Data.CreateProcessRequest.NewProcessId);
             return Reply->Status;
           }
         Reply->Data.CreateProcessReply.InputHandle = ApiReply.Data.AllocConsoleReply.InputHandle;
index 24332dc..a4b3794 100644 (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
  *
@@ -219,6 +219,7 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
   NewBuffer = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_SCREEN_BUFFER));
   if (NULL == NewBuffer)
     {
+      ConioCleanupConsole(Console);
       RtlFreeUnicodeString(&Console->Title);
       RtlDeleteCriticalSection(&Console->Header.Lock);
       CloseHandle(Console->ActiveEvent);
@@ -227,6 +228,7 @@ CsrInitConsole(PCSRSS_CONSOLE Console)
   Status = CsrInitConsoleScreenBuffer(Console, NewBuffer);
   if (! NT_SUCCESS(Status))
     {
+      ConioCleanupConsole(Console);
       RtlFreeUnicodeString(&Console->Title);
       RtlDeleteCriticalSection(&Console->Header.Lock);
       CloseHandle(Console->ActiveEvent);
index 53940ad..44f82e4 100644 (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
  * PROJECT:         ReactOS system libraries
@@ -793,6 +793,7 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   HWND NewWindow;
   LONG WindowCount;
+  MSG Msg;
   PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
 
   switch(msg)
@@ -820,6 +821,14 @@ GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
           }
         return (LRESULT) NewWindow;
       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);
         Console->hWindow = NULL;
         WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);