Skip to content

Commit 9b4066b

Browse files
committed
gh-136306: Handle another allocation failure in get_groups()
1 parent 452bdec commit 9b4066b

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Modules/_ssl.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3465,7 +3465,7 @@ _ssl__SSLContext_get_groups_impl(PySSLContext *self, int include_aliases)
34653465
STACK_OF(OPENSSL_CSTRING) *groups;
34663466
const char *group;
34673467
size_t i, num;
3468-
PyObject *result = NULL;
3468+
PyObject *item, *result;
34693469

34703470
if ((groups = sk_OPENSSL_CSTRING_new_null()) == NULL) {
34713471
_setSSLError(get_state_ctx(self), "Can't allocate stack", 0, __FILE__, __LINE__);
@@ -3488,6 +3488,15 @@ _ssl__SSLContext_get_groups_impl(PySSLContext *self, int include_aliases)
34883488

34893489
for (i = 0; i < num; ++i) {
34903490
group = sk_OPENSSL_CSTRING_value(groups, i);
3491+
item = PyUnicode_DecodeFSDefault(group);
3492+
3493+
if (item == NULL) {
3494+
_setSSLError(get_state_ctx(self), "Can't allocate group name", 0, __FILE__, __LINE__);
3495+
Py_XDECREF(result);
3496+
sk_OPENSSL_CSTRING_free(groups);
3497+
return NULL;
3498+
}
3499+
34913500
PyList_SET_ITEM(result, i, PyUnicode_DecodeFSDefault(group));
34923501
}
34933502

0 commit comments

Comments
 (0)