Skip to content

Commit b1607aa

Browse files
committed
Strengthen refs when frame is copied
1 parent 7a14254 commit b1607aa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Python/frame.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame)
5555
frame = (_PyInterpreterFrame *)f->_f_frame_data;
5656
frame->stackpointer = (_PyStackRef *)(((char *)frame) + size);
5757
frame->f_executable = PyStackRef_DUP(frame->f_executable);
58+
int stacktop = (int)(frame->stackpointer - frame->localsplus);
59+
assert(stacktop >= _PyFrame_GetCode(frame)->co_nlocalsplus);
60+
for (int i = 0; i < stacktop; i++) {
61+
frame->localsplus[i] = _PyStackRef_StealIfUnborrowed(frame->localsplus[i]);
62+
}
5863
f->f_frame = frame;
5964
frame->owner = FRAME_OWNED_BY_FRAME_OBJECT;
6065
if (_PyFrame_IsIncomplete(frame)) {

0 commit comments

Comments
 (0)