Skip to content

Commit 5fdc099

Browse files
dlaugtDaniel Laügt
authored andcommitted
Fix memory access violation on fatal error with Windows
1 parent c5ea8e8 commit 5fdc099

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

Python/pylifecycle.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3079,6 +3079,8 @@ _Py_FatalError_PrintExc(PyThreadState *tstate)
30793079
static void
30803080
fatal_output_debug(const char *msg)
30813081
{
3082+
assert(msg != NULL);
3083+
30823084
/* buffer of 256 bytes allocated on the stack */
30833085
WCHAR buffer[256 / sizeof(WCHAR)];
30843086
size_t buflen = Py_ARRAY_LENGTH(buffer) - 1;
@@ -3360,7 +3362,12 @@ fatal_error(int fd, int header, const char *prefix, const char *msg,
33603362
}
33613363

33623364
#ifdef MS_WINDOWS
3363-
fatal_output_debug(msg);
3365+
if (msg) {
3366+
fatal_output_debug(msg);
3367+
}
3368+
else {
3369+
fatal_output_debug("<message not set>");
3370+
}
33643371
#endif /* MS_WINDOWS */
33653372

33663373
fatal_error_exit(status);

0 commit comments

Comments
 (0)