[NTVDM]: Don't attempt to deinitialize the video console if it wasn't previously...
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 26 Jul 2016 19:57:40 +0000 (19:57 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Tue, 26 Jul 2016 19:57:40 +0000 (19:57 +0000)
CORE-10182 #resolve

svn path=/trunk/; revision=72007

reactos/subsystems/mvdm/ntvdm/console/video.c

index be21647..4746070 100644 (file)
@@ -806,7 +806,10 @@ VOID VgaConsoleRepaintScreen(PSMALL_RECT Rect)
 
 BOOLEAN VgaConsoleInitialize(HANDLE TextHandle)
 {
-    /* Save the default text-mode console output handle */
+    /*
+     * Initialize the console video by saving the default
+     * text-mode console output handle, if it is valid.
+     */
     if (!IsConsoleHandle(TextHandle)) return FALSE;
     TextConsoleBuffer = TextHandle;
 
@@ -814,6 +817,7 @@ BOOLEAN VgaConsoleInitialize(HANDLE TextHandle)
     if (!GetConsoleCursorInfo(TextConsoleBuffer, &OrgConsoleCursorInfo) ||
         !GetConsoleScreenBufferInfo(TextConsoleBuffer, &OrgConsoleBufferInfo))
     {
+        TextConsoleBuffer = NULL;
         return FALSE;
     }
     ConsoleInfo = OrgConsoleBufferInfo;
@@ -826,8 +830,13 @@ BOOLEAN VgaConsoleInitialize(HANDLE TextHandle)
 
 VOID VgaConsoleCleanup(VOID)
 {
+    /* If the console video was not initialized, just return */
+    if (!TextConsoleBuffer)
+        return;
+
     VgaDetachFromConsole();
 
+    // TODO: We need to initialize those events before using them!
     CloseHandle(AnotherEvent);
     CloseHandle(EndEvent);
     CloseHandle(StartEvent);