Skip to content

Commit 87f0156

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

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
@@ -3258,6 +3258,9 @@ new_running_loop_holder(PyObject *loop)
32583258
static void
32593259
PyRunningLoopHolder_tp_dealloc(PyRunningLoopHolder *rl)
32603260
{
3261+
if (cached_running_holder == (PyObject *)rl) {
3262+
cached_running_holder = NULL;
3263+
}
32613264
Py_CLEAR(rl->rl_loop);
32623265
PyObject_Free(rl);
32633266
}

0 commit comments

Comments
 (0)