GetStdHandle may return NULL, which isn't really an error, or INVALID_HANDLE_VALUE...
authorJason Wilkins <Jason.A.Wilkins@gmail.com>
Fri, 27 Jul 2012 10:48:33 +0000 (10:48 +0000)
committerJason Wilkins <Jason.A.Wilkins@gmail.com>
Fri, 27 Jul 2012 10:48:33 +0000 (10:48 +0000)
source/blender/windowmanager/intern/wm_init_exit.c

index bd701cbb3121f3079152a1ffcf6dcee187f9df81..91942a232e16aec8c6721e60b7283cbee842340d 100644 (file)
@@ -335,14 +335,12 @@ extern void free_fmodifiers_copybuf(void);
 extern void free_posebuf(void); 
 
 #if WIN32
-/* read console events until there is a keyboard event, then return */
+/* Read console events until there is a key event.  Also returns on any error. */
 static void wait_for_console_key(void)
 {
-       HANDLE hConsoleInput;
+       HANDLE hConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
 
-       hConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
-
-       if (hConsoleInput && FlushConsoleInputBuffer(hConsoleInput)) {
+       if (!ELEM(hConsoleInput, NULL, INVALID_HANDLE_VALUE) && FlushConsoleInputBuffer(hConsoleInput)) {
                for(;;) {
                        INPUT_RECORD buffer;
                        DWORD ignored;