From 4591dae421cc1415bcf982cccbf5de4f787df030 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Mon, 3 Oct 2022 21:03:26 -0700 Subject: [3.11] GH-97752: Clear the previous member of newly-created generator/coroutine frames (GH-97812) (cherry picked from commit 93fcc1f4133e177882850177c2c047d46019b812) --- Python/frame.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Python') diff --git a/Python/frame.c b/Python/frame.c index c4e93492e08..45072da0426 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -52,6 +52,9 @@ _PyFrame_Copy(_PyInterpreterFrame *src, _PyInterpreterFrame *dest) assert(src->stacktop >= src->f_code->co_nlocalsplus); Py_ssize_t size = ((char*)&src->localsplus[src->stacktop]) - (char *)src; memcpy(dest, src, size); + // Don't leave a dangling pointer to the old frame when creating generators + // and coroutines: + dest->previous = NULL; } -- cgit v1.3.1