[3.11] GH-97752: Clear the previous member of newly-created generator/coroutine frames (GH-97812)

(cherry picked from commit 93fcc1f413)
This commit is contained in:
Miss Islington (bot) 2022-10-03 21:03:26 -07:00 committed by GitHub
parent 0e3a046b48
commit 4591dae421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View file

@ -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;
}