Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-36179: Fix ref leaks in _hashopenssl #12158

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in
out-of-memory cases.
12 changes: 7 additions & 5 deletions Modules/_hashopenssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
vstinner marked this conversation as resolved.
Show resolved Hide resolved
PyErr_NoMemory();
return NULL;
}

/* save the name for .name to return */
Py_INCREF(name);
retval->name = name;
retval->lock = NULL;

return retval;
}

Expand Down Expand Up @@ -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;
Expand Down