Skip to content

Commit a59d33a

Browse files
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 (cherry picked from commit b7bc283) Co-authored-by: Christian Heimes <christian@python.org>
1 parent 06e9953 commit a59d33a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix two unlikely reference leaks in _hashopenssl. The leaks only occur in
2+
out-of-memory cases.

Modules/_hashopenssl.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,18 @@ newEVPobject(PyObject *name)
112112
return NULL;
113113
}
114114

115+
/* save the name for .name to return */
116+
Py_INCREF(name);
117+
retval->name = name;
118+
retval->lock = NULL;
119+
115120
retval->ctx = EVP_MD_CTX_new();
116121
if (retval->ctx == NULL) {
122+
Py_DECREF(retval);
117123
PyErr_NoMemory();
118124
return NULL;
119125
}
120126

121-
/* save the name for .name to return */
122-
Py_INCREF(name);
123-
retval->name = name;
124-
retval->lock = NULL;
125-
126127
return retval;
127128
}
128129

@@ -181,6 +182,7 @@ EVP_copy(EVPobject *self, PyObject *unused)
181182
return NULL;
182183

183184
if (!locked_EVP_MD_CTX_copy(newobj->ctx, self)) {
185+
Py_DECREF(newobj);
184186
return _setException(PyExc_ValueError);
185187
}
186188
return (PyObject *)newobj;

0 commit comments

Comments
 (0)
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