summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-03-04 15:45:41 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-03-04 15:45:41 (GMT)
commitb7bc283ab6a23ee98784400ebffe7fe410232a2e (patch)
tree8e6e015b9376688705b2a8bae03564315c98e667 /Modules
parent800d5cd75025876d79ab05980925a05d8e36b63d (diff)
downloadcpython-b7bc283ab6a23ee98784400ebffe7fe410232a2e.zip
cpython-b7bc283ab6a23ee98784400ebffe7fe410232a2e.tar.gz
cpython-b7bc283ab6a23ee98784400ebffe7fe410232a2e.tar.bz2
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
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_hashopenssl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/_hashopenssl.c b/Modules/_hashopenssl.c
index 9091025..aae558c 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;