From 02efbee4f639ae2ab381f6a4502f0a237afe1f01 Mon Sep 17 00:00:00 2001 From: Karsten Blees Date: Thu, 15 Mar 2012 14:45:49 +0100 Subject: [PATCH] Win32: fix segfault in WriteConsoleW when debugging in gdb On Windows XP (not Win7), WriteConsoleW and WriteFile seem to raise and catch SIGSEGV if the lpNumberOfCharsWritten parameter is NULL. This is not a problem when executed standalone, but gdb stops execution here (unless disabled via "handle SIGSEGV nostop"). Fix it by passing a dummy variable. Signed-off-by: Karsten Blees --- compat/winansi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compat/winansi.c b/compat/winansi.c index 040ef5adca..13bc28dd33 100644 --- a/compat/winansi.c +++ b/compat/winansi.c @@ -72,7 +72,8 @@ static void warn_if_raster_font(void) L"doesn\'t support Unicode. If you experience strange " L"characters in the output, consider switching to a " L"TrueType font such as Lucida Console!\n"; - WriteConsoleW(console, msg, wcslen(msg), NULL, NULL); + DWORD dummy; + WriteConsoleW(console, msg, wcslen(msg), &dummy, NULL); } } @@ -114,12 +115,13 @@ static void write_console(unsigned char *str, size_t len) { /* only called from console_thread, so a static buffer will do */ static wchar_t wbuf[2 * BUFFER_SIZE + 1]; + DWORD dummy; /* convert utf-8 to utf-16 */ int wlen = xutftowcsn(wbuf, (char*) str, ARRAY_SIZE(wbuf), len); /* write directly to console */ - WriteConsoleW(console, wbuf, wlen, NULL, NULL); + WriteConsoleW(console, wbuf, wlen, &dummy, NULL); /* remember if non-ascii characters are printed */ if (wlen != len) -- 2.11.4.GIT