Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 9d86323

Browse files
kbleeskasal
authored andcommitted
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 <[email protected]>
1 parent 366e03f commit 9d86323

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

compat/winansi.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ static void warn_if_raster_font(void)
7272
L"doesn\'t support Unicode. If you experience strange "
7373
L"characters in the output, consider switching to a "
7474
L"TrueType font such as Lucida Console!\n";
75-
WriteConsoleW(console, msg, wcslen(msg), NULL, NULL);
75+
DWORD dummy;
76+
WriteConsoleW(console, msg, wcslen(msg), &dummy, NULL);
7677
}
7778
}
7879

@@ -114,12 +115,13 @@ static void write_console(unsigned char *str, size_t len)
114115
{
115116
/* only called from console_thread, so a static buffer will do */
116117
static wchar_t wbuf[2 * BUFFER_SIZE + 1];
118+
DWORD dummy;
117119

118120
/* convert utf-8 to utf-16 */
119121
int wlen = xutftowcsn(wbuf, (char*) str, ARRAY_SIZE(wbuf), len);
120122

121123
/* write directly to console */
122-
WriteConsoleW(console, wbuf, wlen, NULL, NULL);
124+
WriteConsoleW(console, wbuf, wlen, &dummy, NULL);
123125

124126
/* remember if non-ascii characters are printed */
125127
if (wlen != len)

0 commit comments

Comments
 (0)