aboutsummaryrefslogtreecommitdiff
path: root/libavutil
diff options
context:
space:
mode:
authorMarton Balint2020-01-29 00:46:01 +0100
committerMarton Balint2020-02-09 20:31:44 +0100
commit1b34c0690f0c159ea528c2ccd6c0811e450896b6 (patch)
tree5fd23eca101a15da9a12e30601e53d96dc463252 /libavutil
parentbad8feb5e66618a4122c539fc7187607e989d7ed (diff)
avutil/log: fix detecting console mode on Win32
A redirected stderr can still have a valid handle. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/log.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/libavutil/log.c b/libavutil/log.c
index 64950016e8..6374050770 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -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);