From 3fc9c9522d41ee4383f9d7ec6fc8583db9289324 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 20 May 2018 03:15:22 +0200 Subject: [PATCH] Codechange: [Win32] Use a local buffer to store the output text of DEBUG() to make the call thread-safe. --- src/debug.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/debug.cpp b/src/debug.cpp index d4d547c884..f8f3f0ad56 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -17,6 +17,10 @@ #include "fileio_func.h" #include "settings_type.h" +#if defined(WIN32) || defined(WIN64) +#include "os/windows/win32.h" +#endif + #include #if defined(ENABLE_NETWORK) @@ -136,7 +140,9 @@ static void debug_print(const char *dbg, const char *buf) char buffer[512]; seprintf(buffer, lastof(buffer), "%sdbg: [%s] %s\n", GetLogPrefix(), dbg, buf); #if defined(WIN32) || defined(WIN64) - _fputts(OTTD2FS(buffer, true), stderr); + TCHAR system_buf[512]; + convert_to_fs(buffer, system_buf, lengthof(system_buf), true); + _fputts(system_buf, stderr); #else fputs(buffer, stderr); #endif