Skip to content

Commit 37c57df

Browse files
gh-126405: fix use-after-free in _asyncio.Future.remove_done_callback (#126733)
1 parent 0ef84b0 commit 37c57df

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Modules/_asynciomodule.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,10 @@ _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
10171017

10181018
if (len == 1) {
10191019
PyObject *cb_tup = PyList_GET_ITEM(self->fut_callbacks, 0);
1020+
Py_INCREF(cb_tup);
10201021
int cmp = PyObject_RichCompareBool(
10211022
PyTuple_GET_ITEM(cb_tup, 0), fn, Py_EQ);
1023+
Py_DECREF(cb_tup);
10221024
if (cmp == -1) {
10231025
return NULL;
10241026
}

0 commit comments

Comments
 (0)