diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-05-12 18:45:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-12 18:45:06 (GMT) |
commit | 1ee58f252454072a1c9da77999db8e6417a307a0 (patch) | |
tree | 498cb654b03c958680e0c19e4771e2e6f02cc7df /Modules | |
parent | a2d94a0a9b8ae95d7d2b7fc34b501da5242ec22c (diff) | |
download | cpython-1ee58f252454072a1c9da77999db8e6417a307a0.zip cpython-1ee58f252454072a1c9da77999db8e6417a307a0.tar.gz cpython-1ee58f252454072a1c9da77999db8e6417a307a0.tar.bz2 |
bpo-40645: Fix ref leaks in _hashopenssl (GH-26079)
(cherry picked from commit 504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_hashopenssl.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index b2c6775..e4a2885 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -2093,20 +2093,25 @@ hashlib_init_constructors(PyObject *module) } func = PyObject_GetAttrString(module, fdef->ml_name); if (func == NULL) { + Py_DECREF(name_obj); return -1; } - if (PyDict_SetItem(state->constructs, func, name_obj) < 0) { - return -1; - } + int rc = PyDict_SetItem(state->constructs, func, name_obj); Py_DECREF(func); Py_DECREF(name_obj); + if (rc < 0) { + return -1; + } } proxy = PyDictProxy_New(state->constructs); if (proxy == NULL) { return -1; } - if (PyModule_AddObjectRef(module, "_constructors", proxy) < 0) { + + int rc = PyModule_AddObjectRef(module, "_constructors", proxy); + Py_DECREF(proxy); + if (rc < 0) { return -1; } return 0; |