Skip to content

Commit 6846d67

Browse files
bpo-45262, asyncio: Fix cache of the running loop holder (GH-28796) (GH-28816)
Prevent use-after-free of running loop holder via cache. (cherry picked from commit 392a898) Co-authored-by: Matthias Reichl <[email protected]>
1 parent 4ce55a2 commit 6846d67

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent use-after-free in asyncio. Make sure the cached running loop holder gets cleared on dealloc to prevent use-after-free in get_running_loop

Modules/_asynciomodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3239,6 +3239,9 @@ new_running_loop_holder(PyObject *loop)
32393239
static void
32403240
PyRunningLoopHolder_tp_dealloc(PyRunningLoopHolder *rl)
32413241
{
3242+
if (cached_running_holder == (PyObject *)rl) {
3243+
cached_running_holder = NULL;
3244+
}
32423245
Py_CLEAR(rl->rl_loop);
32433246
PyObject_Free(rl);
32443247
}

0 commit comments

Comments
 (0)