Skip to content

Commit b13b84a

Browse files
[3.12] gh-126405: fix use-after-free in _asyncio.Future.remove_done_callback (GH-126733) (#126737)
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 86efa2f commit b13b84a

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

10741074
if (len == 1) {
10751075
PyObject *cb_tup = PyList_GET_ITEM(self->fut_callbacks, 0);
1076+
Py_INCREF(cb_tup);
10761077
int cmp = PyObject_RichCompareBool(
10771078
PyTuple_GET_ITEM(cb_tup, 0), fn, Py_EQ);
1079+
Py_DECREF(cb_tup);
10781080
if (cmp == -1) {
10791081
return NULL;
10801082
}

0 commit comments

Comments
 (0)