From 40dd2571c21a2bb6ea421e7aa668e0d8beeffb97 Mon Sep 17 00:00:00 2001 From: Misa Date: Mon, 14 Nov 2022 21:56:02 -0800 Subject: [PATCH] Add error checks to `freopen` calls on Windows I don't know if they could fail but it's still good to attempt to print _something_ if they do end up failing. --- desktop_version/src/Vlogging.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Vlogging.c b/desktop_version/src/Vlogging.c index 79041caf..a88b9616 100644 --- a/desktop_version/src/Vlogging.c +++ b/desktop_version/src/Vlogging.c @@ -181,8 +181,17 @@ void vlog_open_console(void) return; } - freopen("CON", "w", stdout); - freopen("CON", "w", stderr); + const FILE* handle = freopen("CON", "w", stdout); + if (handle == NULL) + { + vlog_error("Could not redirect STDOUT to console."); + } + + handle = freopen("CON", "w", stderr); + if (handle == NULL) + { + vlog_error("Could not redirect STDERR to console."); + } check_color_support(); }