Skip to content

Commit

Permalink
bpo-38823: Fix refleaks in faulthandler init error path on Windows (G…
Browse files Browse the repository at this point in the history
…H-17250)

(cherry picked from commit ac22354)

Co-authored-by: Brandt Bucher <[email protected]>
  • Loading branch information
miss-islington and brandtbucher authored Nov 19, 2019
1 parent 4ffc569 commit 5bd2af9
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,25 +1273,36 @@ PyInit_faulthandler(void)
#ifdef MS_WINDOWS
/* RaiseException() codes (prefixed by an underscore) */
if (PyModule_AddIntConstant(m, "_EXCEPTION_ACCESS_VIOLATION",
EXCEPTION_ACCESS_VIOLATION))
return NULL;
EXCEPTION_ACCESS_VIOLATION)) {
goto error;
}
if (PyModule_AddIntConstant(m, "_EXCEPTION_INT_DIVIDE_BY_ZERO",
EXCEPTION_INT_DIVIDE_BY_ZERO))
return NULL;
EXCEPTION_INT_DIVIDE_BY_ZERO)) {
goto error;
}
if (PyModule_AddIntConstant(m, "_EXCEPTION_STACK_OVERFLOW",
EXCEPTION_STACK_OVERFLOW))
return NULL;
EXCEPTION_STACK_OVERFLOW)) {
goto error;
}

/* RaiseException() flags (prefixed by an underscore) */
if (PyModule_AddIntConstant(m, "_EXCEPTION_NONCONTINUABLE",
EXCEPTION_NONCONTINUABLE))
return NULL;
EXCEPTION_NONCONTINUABLE)) {
goto error;
}
if (PyModule_AddIntConstant(m, "_EXCEPTION_NONCONTINUABLE_EXCEPTION",
EXCEPTION_NONCONTINUABLE_EXCEPTION))
return NULL;
EXCEPTION_NONCONTINUABLE_EXCEPTION)) {
goto error;
}
#endif

return m;

#ifdef MS_WINDOWS
error:
Py_DECREF(m);
return NULL;
#endif
}

static int
Expand Down

0 comments on commit 5bd2af9

Please sign in to comment.