From a64928172f2a0520769e9c44f3550cd0e7051ac2 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Mon, 4 Mar 2019 10:43:11 +0100 Subject: [PATCH] bpo-36179: Fix ref leaks in _hashopenssl 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 --- .../Library/2019-03-04-10-42-46.bpo-36179.jEyuI-.rst | 2 ++ Modules/_hashopenssl.c | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2019-03-04-10-42-46.bpo-36179.jEyuI-.rst diff --git a/Misc/NEWS.d/next/Library/2019-03-04-10-42-46.bpo-36179.jEyuI-.rst b/Misc/NEWS.d/next/Library/2019-03-04-10-42-46.bpo-36179.jEyuI-.rst new file mode 100644 index 00000000000000..61a98778b78e9d --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-03-04-10-42-46.bpo-36179.jEyuI-.rst @@ -0,0 +1,2 @@ +Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in +out-of-memory cases. diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c index 9091025761b965..aae558c9930301 100644 --- a/Modules/_hashopenssl.c +++ b/Modules/_hashopenssl.c @@ -109,17 +109,18 @@ newEVPobject(PyObject *name) 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; } - /* save the name for .name to return */ - Py_INCREF(name); - retval->name = name; - retval->lock = 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; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy