8000 Enforce conditions on the internal tuple · python/cpython@f7b6730 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7b6730

Browse files
committed
Enforce conditions on the internal tuple
1 parent 22b21cc commit f7b6730

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/_asynciomodule.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ future_schedule_callbacks(asyncio_state *state, FutureObj *fut)
457457
break; // done
458458
}
459459
PyObject *cb_tup = PyList_GET_ITEM(fut->fut_callbacks, i);
460-
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) < 2) {
460+
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) != 2) {
461461
PyErr_SetString(PyExc_RuntimeError, "corrupted callback tuple");
462462
return -1;
463463
}
@@ -1073,7 +1073,7 @@ _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
10731073
// Beware: An evil PyObject_RichCompareBool could change fut_callbacks
10741074
// or its items (see https://github.com/python/cpython/issues/97592 or
10751075
// https://github.com/python/cpython/issues/125789 for details).
1076-
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) < 1) {
1076+
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) != 2) {
10771077
PyErr_SetString(PyExc_RuntimeError, "corrupted callback tuple");
10781078
return NULL;
10791079
}
@@ -1110,7 +1110,7 @@ _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
11101110
break; // done
11111111
}
11121112
PyObject *cb_tup = PyList_GET_ITEM(self->fut_callbacks, i);
1113-
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) < 1) {
1113+
if (!PyTuple_CheckExact(cb_tup) || PyTuple_GET_SIZE(cb_tup) != 2) {
11141114
PyErr_SetString(PyExc_RuntimeError, "corrupted callback tuple");
11151115
goto fail;
11161116
}

0 commit comments

Comments
 (0)
0