summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2022-10-03 23:36:52 (GMT)
committerGitHub <noreply@github.com>2022-10-03 23:36:52 (GMT)
commit93fcc1f4133e177882850177c2c047d46019b812 (patch)
tree523560275ae44387a418e9f18c0df6eb2a69993f /Python
parentd053c47bfde1b3d8779546b980849708662f2660 (diff)
downloadcpython-93fcc1f4133e177882850177c2c047d46019b812.zip
cpython-93fcc1f4133e177882850177c2c047d46019b812.tar.gz
cpython-93fcc1f4133e177882850177c2c047d46019b812.tar.bz2
GH-97752: Clear the `previous` member of newly-created generator/coroutine frames (GH-97795)
Diffstat (limited to 'Python')
-rw-r--r--Python/frame.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/frame.c b/Python/frame.c
index 14464df..05a8cff 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -54,6 +54,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;
}