From bf84d8152b840deb38e02b42699a6e578c7188bc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 16 Oct 2024 16:54:15 +0200 Subject: [PATCH] do not set console mode from an uninitialized variable. --- src/common/platform/win32/i_main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/platform/win32/i_main.cpp b/src/common/platform/win32/i_main.cpp index ce2fabe606..c68b5a7aa1 100644 --- a/src/common/platform/win32/i_main.cpp +++ b/src/common/platform/win32/i_main.cpp @@ -197,10 +197,14 @@ int DoMain (HINSTANCE hInstance) SetConsoleCP(CP_UTF8); SetConsoleOutputCP(CP_UTF8); + DWORD mode; - if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) - FancyStdOut = IsWindows10OrGreater(); // Windows 8.1 and lower do not understand ANSI formatting. + if (GetConsoleMode(StdOut, &mode)) + { + if (SetConsoleMode(StdOut, mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) + FancyStdOut = IsWindows10OrGreater(); // Windows 8.1 and lower do not understand ANSI formatting. + } } else if (Args->CheckParm("-stdout") || Args->CheckParm("-norun")) {