diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-11-19 23:31:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 23:31:08 (GMT) |
commit | a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10 (patch) | |
tree | e0bc83e5afafe7a5e22f552862f837d753176f38 /Modules/faulthandler.c | |
parent | 829593a9262e67c72167c6cb20d383203b2ea410 (diff) | |
download | cpython-a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10.zip cpython-a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10.tar.gz cpython-a5ed2fe0eedefa1649aa93ee74a0bafc8e628a10.tar.bz2 |
bpo-38823: Fix refleaks in faulthandler init error path on Windows (GH-17250)
(cherry picked from commit ac2235432c607ce2c0faf6dff5d9b2534d2f6652)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
Diffstat (limited to 'Modules/faulthandler.c')
-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 7b32599..251d8e0 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -1276,25 +1276,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 |