]> git.sesse.net Git - ffmpeg/commitdiff
avutil/log: fix detecting console mode on Win32
authorMarton Balint <cus@passwd.hu>
Tue, 28 Jan 2020 23:46:01 +0000 (00:46 +0100)
committerMarton Balint <cus@passwd.hu>
Sun, 9 Feb 2020 19:31:44 +0000 (20:31 +0100)
A redirected stderr can still have a valid handle.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavutil/log.c

index 64950016e89b1b7b1f100fd1a777a081233b6cba..63740507704129fd0ccd4b18194259cdf18fae8a 100644 (file)
@@ -124,7 +124,10 @@ static void check_color_terminal(void)
 {
 #if defined(_WIN32) && HAVE_SETCONSOLETEXTATTRIBUTE && HAVE_GETSTDHANDLE
     CONSOLE_SCREEN_BUFFER_INFO con_info;
+    DWORD dummy;
     con = GetStdHandle(STD_ERROR_HANDLE);
+    if (con != INVALID_HANDLE_VALUE && !GetConsoleMode(con, &dummy))
+        con = INVALID_HANDLE_VALUE;
     use_color = (con != INVALID_HANDLE_VALUE) && !getenv("AV_LOG_FORCE_NOCOLOR");
     if (use_color) {
         GetConsoleScreenBufferInfo(con, &con_info);