Skip to content

Commit 39df95e

Browse files
Do not try to allocate too much space.
1 parent 48291af commit 39df95e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Modules/_xxsubinterpretersmodule.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,12 @@ _channels_list_all(_channels *channels, int64_t *count)
854854
{
855855
int64_t *cids = NULL;
856856
PyThread_acquire_lock(channels->mutex, WAIT_LOCK);
857-
int64_t *ids = PyMem_NEW(int64_t, channels->numopen);
857+
int64_t numopen = channels->numopen;
858+
if (numopen >= PY_SSIZE_T_MAX) {
859+
PyErr_SetString(PyExc_RuntimeError, "too many channels open");
860+
goto done;
861+
}
862+
int64_t *ids = PyMem_NEW(int64_t, (Py_ssize_t)(channels->numopen));
858863
if (ids == NULL) {
859864
goto done;
860865
}

0 commit comments

Comments
 (0)