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 392a898353)

Co-authored-by: Matthias Reichl <github@hias.horus.com>
This commit is contained in:
Miss Islington (bot) 2021-10-07 16:14:04 -07:00 committed by GitHub
parent 06935bd68e
commit 87f0156a22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -3258,6 +3258,9 @@ new_running_loop_holder(PyObject *loop)
static void
PyRunningLoopHolder_tp_dealloc(PyRunningLoopHolder *rl)
{
if (cached_running_holder == (PyObject *)rl) {
cached_running_holder = NULL;
}
Py_CLEAR(rl->rl_loop);
PyObject_Free(rl);
}