gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (#126733)

This commit is contained in:
Kumar Aditya 2024-11-12 18:01:34 +05:30 committed by GitHub
parent 0ef84b0e2b
commit 37c57dfad1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 0 deletions

View File

@ -1017,8 +1017,10 @@ _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
if (len == 1) {
PyObject *cb_tup = PyList_GET_ITEM(self->fut_callbacks, 0);
Py_INCREF(cb_tup);
int cmp = PyObject_RichCompareBool(
PyTuple_GET_ITEM(cb_tup, 0), fn, Py_EQ);
Py_DECREF(cb_tup);
if (cmp == -1) {
return NULL;
}