https://github.com/python/cpython/commit/b13b84ab707bbc06b26a1ed4fb58253ff309c5dd
commit: b13b84ab707bbc06b26a1ed4fb58253ff309c5dd
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2024-11-12T13:04:25Z
summary:

[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 37c57dfad12744608091653fd753a1f770e2479b)

Co-authored-by: Kumar Aditya <[email protected]>

files:
M Modules/_asynciomodule.c

diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 20a9d992834b0e..2356b708ee88b4 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -1073,8 +1073,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;
         }

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to