mirror of https://github.com/python/cpython
bpo-36179: Fix ref leaks in _hashopenssl (GH-12158)
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in out-of-memory cases. Thanks to Charalampos Stratakis. Signed-off-by: Christian Heimes <christian@python.org> https://bugs.python.org/issue36179
This commit is contained in:
parent
800d5cd750
commit
b7bc283ab6
|
@ -0,0 +1,2 @@
|
|||
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in
|
||||
out-of-memory cases.
|
|
@ -109,17 +109,18 @@ newEVPobject(PyObject *name)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
retval->ctx = EVP_MD_CTX_new();
|
||||
if (retval->ctx == NULL) {
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* save the name for .name to return */
|
||||
Py_INCREF(name);
|
||||
retval->name = name;
|
||||
retval->lock = NULL;
|
||||
|
||||
retval->ctx = EVP_MD_CTX_new();
|
||||
if (retval->ctx == NULL) {
|
||||
Py_DECREF(retval);
|
||||
PyErr_NoMemory();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -182,6 +183,7 @@ EVP_copy_impl(EVPobject *self)
|
|||
return NULL;
|
||||
|
||||
if (!locked_EVP_MD_CTX_copy(newobj->ctx, self)) {
|
||||
Py_DECREF(newobj);
|
||||
return _setException(PyExc_ValueError);
|
||||
}
|
||||
return (PyObject *)newobj;
|
||||
|
|
Loading…
Reference in New Issue