From: Jacob Nevins Date: Sun, 8 Dec 2002 14:44:42 +0000 (+0000) Subject: Argh. With DEBUG and MALLOC_LOG enabled, I found output intended for the X-Git-Tag: r8855-g4f798d~1959 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=918bad5ddd82ef03e950d11090f39acf417045fc;p=PuTTY_svn.git Argh. With DEBUG and MALLOC_LOG enabled, I found output intended for the console was ending up in one or other of debug.log or putty_mem.log. I don't really understand why, but I've put some extra paranoia and caching in debug(()) and that seems to have fixed it (tm). Perhaps I can get back to debugging... git-svn-id: http://svn.tartarus.org/sgt/putty@2291 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/misc.c b/misc.c index 6b2f9e68..496d30e3 100644 --- a/misc.c +++ b/misc.c @@ -592,6 +592,7 @@ void safefree(void *ptr) #ifdef DEBUG static FILE *debug_fp = NULL; +static HANDLE debug_hdl = INVALID_HANDLE_VALUE; static int debug_got_console = 0; static void dputs(char *buf) @@ -599,15 +600,18 @@ static void dputs(char *buf) DWORD dw; if (!debug_got_console) { - AllocConsole(); - debug_got_console = 1; + if (AllocConsole()) { + debug_got_console = 1; + debug_hdl = GetStdHandle(STD_OUTPUT_HANDLE); + } } if (!debug_fp) { debug_fp = fopen("debug.log", "w"); } - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, strlen(buf), &dw, - NULL); + if (debug_hdl != INVALID_HANDLE_VALUE) { + WriteFile(debug_hdl, buf, strlen(buf), &dw, NULL); + } fputs(buf, debug_fp); fflush(debug_fp); }