diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2019-11-19 23:13:05 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@python.org> | 2019-11-19 23:13:05 (GMT) |
commit | ac2235432c607ce2c0faf6dff5d9b2534d2f6652 (patch) | |
tree | ea57e314e1ab90f7c6895d389d347001d4c3c8a3 /Modules | |
parent | 293dd23477eef6e7c1b1e26b5bb2c1e0d79ac3c2 (diff) | |
download | cpython-ac2235432c607ce2c0faf6dff5d9b2534d2f6652.zip cpython-ac2235432c607ce2c0faf6dff5d9b2534d2f6652.tar.gz cpython-ac2235432c607ce2c0faf6dff5d9b2534d2f6652.tar.bz2 |
bpo-38823: Fix refleaks in faulthandler init error path on Windows (GH-17250)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/faulthandler.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index 129a104..d128053 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1334,25 +1334,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 |