bpo-40645: Fix reference leak in the _hashopenssl extension (GH-25063)

This commit is contained in:
Pablo Galindo 2021-03-29 14:17:40 +01:00 committed by GitHub
parent 9b999479c0
commit 70cdf1812c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -0,0 +1,2 @@
Fix reference leak in the :mod:`_hashopenssl` extension. Patch by Pablo
Galindo.

View file

@ -865,7 +865,7 @@ EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj,
/*[clinic end generated code: output=ddd5053f92dffe90 input=c24554d0337be1b0]*/
{
Py_buffer view = { 0 };
PyObject *ret_obj;
PyObject *ret_obj = NULL;
char *name;
const EVP_MD *digest = NULL;
@ -879,13 +879,14 @@ EVP_new_impl(PyObject *module, PyObject *name_obj, PyObject *data_obj,
digest = py_digest_by_name(name);
if (digest == NULL) {
return NULL;
goto exit;
}
ret_obj = EVPnew(module, digest,
(unsigned char*)view.buf, view.len,
usedforsecurity);
exit:
if (data_obj)
PyBuffer_Release(&view);
return ret_obj;