Commit b7bc283a authored by Christian Heimes's avatar Christian Heimes Committed by Miss Islington (bot)

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: default avatarChristian Heimes <christian@python.org>



https://bugs.python.org/issue36179
parent 800d5cd7
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in
out-of-memory cases.
...@@ -109,17 +109,18 @@ newEVPobject(PyObject *name) ...@@ -109,17 +109,18 @@ newEVPobject(PyObject *name)
return NULL; return NULL;
} }
/* save the name for .name to return */
Py_INCREF(name);
retval->name = name;
retval->lock = NULL;
retval->ctx = EVP_MD_CTX_new(); retval->ctx = EVP_MD_CTX_new();
if (retval->ctx == NULL) { if (retval->ctx == NULL) {
Py_DECREF(retval);
PyErr_NoMemory(); PyErr_NoMemory();
return NULL; return NULL;
} }
/* save the name for .name to return */
Py_INCREF(name);
retval->name = name;
retval->lock = NULL;
return retval; return retval;
} }
...@@ -182,6 +183,7 @@ EVP_copy_impl(EVPobject *self) ...@@ -182,6 +183,7 @@ EVP_copy_impl(EVPobject *self)
return NULL; return NULL;
if (!locked_EVP_MD_CTX_copy(newobj->ctx, self)) { if (!locked_EVP_MD_CTX_copy(newobj->ctx, self)) {
Py_DECREF(newobj);
return _setException(PyExc_ValueError); return _setException(PyExc_ValueError);
} }
return (PyObject *)newobj; return (PyObject *)newobj;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment