]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (#126733)
authorKumar Aditya <kumaraditya@python.org>
Tue, 12 Nov 2024 12:31:34 +0000 (18:01 +0530)
committerGitHub <noreply@github.com>
Tue, 12 Nov 2024 12:31:34 +0000 (18:01 +0530)
Modules/_asynciomodule.c

index 617a3dca35d9c257c3dc59e65e6301d0ccc72dcc..f883125a2c70b26cb0909467fd1734612a272f47 100644 (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;
         }