summaryrefslogtreecommitdiffstats
path: root/Python/frame.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-07-04 18:43:12 (GMT)
committerGitHub <noreply@github.com>2022-07-04 18:43:12 (GMT)
commit68f5fa668343341b79ce1e23f1d9e773b98fd312 (patch)
treebc9b4ab897d1addc94ebf52c643e720fb75944d7 /Python/frame.c
parent8fe0b1d8fa3451e923d7632263be6145a0734468 (diff)
downloadcpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.zip
cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.gz
cpython-68f5fa668343341b79ce1e23f1d9e773b98fd312.tar.bz2
[3.11] GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371) (#94482)
Co-authored-by: Mark Shannon <mark@hotpy.org>
Diffstat (limited to 'Python/frame.c')
-rw-r--r--Python/frame.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/frame.c b/Python/frame.c
index b6674ed..c4e9349 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -66,9 +66,13 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
f->f_frame = frame;
frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
assert(f->f_back == NULL);
- if (frame->previous != NULL) {
+ _PyInterpreterFrame *prev = frame->previous;
+ while (prev && _PyFrame_IsIncomplete(prev)) {
+ prev = prev->previous;
+ }
+ if (prev) {
/* Link PyFrameObjects.f_back and remove link through _PyInterpreterFrame.previous */
- PyFrameObject *back = _PyFrame_GetFrameObject(frame->previous);
+ PyFrameObject *back = _PyFrame_GetFrameObject(prev);
if (back == NULL) {
/* Memory error here. */
assert(PyErr_ExceptionMatches(PyExc_MemoryError));