[Python-checkins] bpo-40645: Fix reference leak in the _hashopenssl extension (GH-25063)

miss-islington webhook-mailer at python.org
Mon Mar 29 09:17:45 EDT 2021


https://github.com/python/cpython/commit/70cdf1812cf479c6b1cd7435a6fc0679ec1fb0da
commit: 70cdf1812cf479c6b1cd7435a6fc0679ec1fb0da
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-03-29T06:17:40-07:00
summary:

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

files:
A Misc/NEWS.d/next/Core and Builtins/2021-03-29-11-55-06.bpo-40645.PhaT-B.rst
M Modules/_hashopenssl.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-03-29-11-55-06.bpo-40645.PhaT-B.rst b/Misc/NEWS.d/next/Core and Builtins/2021-03-29-11-55-06.bpo-40645.PhaT-B.rst
new file mode 100644
index 0000000000000..9ca9843947547
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and Builtins/2021-03-29-11-55-06.bpo-40645.PhaT-B.rst	
@@ -0,0 +1,2 @@
+Fix reference leak in the :mod:`_hashopenssl` extension. Patch by Pablo
+Galindo.
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 6c83b9e4a41fa..ef927abf4859f 100644
--- a/Modules/_hashopenssl.c
+++ b/Modules/_hashopenssl.c
@@ -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;



More information about the Python-checkins mailing list