summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend Egeberg Aasland <erlend.aasland@innova.no>2021-05-12 18:20:41 (GMT)
committerGitHub <noreply@github.com>2021-05-12 18:20:41 (GMT)
commit504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e (patch)
tree3168a07d70852e58de714798ff1990b321182486
parente5ba1fe995d4b4f3f6a089a7ec4dd186dd573830 (diff)
downloadcpython-504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e.zip
cpython-504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e.tar.gz
cpython-504ffdae4e0cb7775f3e584c3b1d20c262fdfd7e.tar.bz2
bpo-40645: Fix ref leaks in _hashopenssl (GH-26079)
-rw-r--r--Modules/_hashopenssl.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 13634a5..e4a2885 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -2093,23 +2093,27 @@ 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;
}
- Py_DECREF(proxy);
return 0;
}