summaryrefslogtreecommitdiffstats
path: root/Python/frame.c
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2022-07-01 10:08:20 (GMT)
committerGitHub <noreply@github.com>2022-07-01 10:08:20 (GMT)
commit544531de23d69f5b23883794fc7bb23a958a0fcb (patch)
treead88c0a6543127cd89027843ab441aa29dbdbc75 /Python/frame.c
parent1df9449db24f16c9c96bdd7dc283a5062bca68e6 (diff)
downloadcpython-544531de23d69f5b23883794fc7bb23a958a0fcb.zip
cpython-544531de23d69f5b23883794fc7bb23a958a0fcb.tar.gz
cpython-544531de23d69f5b23883794fc7bb23a958a0fcb.tar.bz2
GH-94262: Don't create frame objects for frames that aren't yet complete. (GH-94371)
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 206ecab..7c6705e 100644
--- a/Python/frame.c
+++ b/Python/frame.c
@@ -68,9 +68,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));