mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-40645: Fix ref leaks in _hashopenssl (GH-26079)
(cherry picked from commit 504ffdae4e
)
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
This commit is contained in:
parent
a2d94a0a9b
commit
1ee58f2524
1 changed files with 9 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue