Skip to content

Commit 2da063e

Browse files
[3.13] gh-126405: fix use-after-free in _asyncio.Future.remove_done_callback (GH-126733) (#126736)
gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (GH-126733) (cherry picked from commit 37c57df) Co-authored-by: Kumar Aditya <[email protected]>
1 parent 02cd3ce commit 2da063e

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
@@ -994,8 +994,10 @@ _asyncio_Future_remove_done_callback_impl(FutureObj *self, PyTypeObject *cls,
994994

995995
if (len == 1) {
996996
PyObject *cb_tup = PyList_GET_ITEM(self->fut_callbacks, 0);
997+
Py_INCREF(cb_tup);
997998
int cmp = PyObject_RichCompareBool(
998999
PyTuple_GET_ITEM(cb_tup, 0), fn, Py_EQ);
1000+
Py_DECREF(cb_tup);
9991001
if (cmp == -1) {
10001002
return NULL;
10011003
}

0 commit comments

Comments
 (0)