@@ -148,17 +148,26 @@ _PyFrame_NumSlotsForCodeObject(PyCodeObject *code)
148148
149149static  inline  void  _PyFrame_Copy (_PyInterpreterFrame  * src , _PyInterpreterFrame  * dest )
150150{
151-     * dest  =  * src ;
151+     dest -> f_executable  =  PyStackRef_MakeHeapSafe (src -> f_executable );
152+     // Don't leave a dangling pointer to the old frame when creating generators 
153+     // and coroutines: 
154+     dest -> previous  =  NULL ;
155+     dest -> f_funcobj  =  PyStackRef_MakeHeapSafe (src -> f_funcobj );
156+     dest -> f_globals  =  src -> f_globals ;
157+     dest -> f_builtins  =  src -> f_builtins ;
158+     dest -> f_locals  =  src -> f_locals ;
159+     dest -> frame_obj  =  src -> frame_obj ;
160+     dest -> instr_ptr  =  src -> instr_ptr ;
161+ #ifdef  Py_GIL_DISABLED 
162+     dest -> tlbc_index  =  src -> tlbc_index ;
163+ #endif 
152164    assert (src -> stackpointer  !=  NULL );
153165    int  stacktop  =  (int )(src -> stackpointer  -  src -> localsplus );
154-     assert (stacktop  >= _PyFrame_GetCode ( src ) -> co_nlocalsplus );
166+     assert (stacktop  >= 0 );
155167    dest -> stackpointer  =  dest -> localsplus  +  stacktop ;
156-     for  (int  i  =  1 ; i  <  stacktop ; i ++ ) {
157-         dest -> localsplus [i ] =  src -> localsplus [i ];
168+     for  (int  i  =  0 ; i  <  stacktop ; i ++ ) {
169+         dest -> localsplus [i ] =  PyStackRef_MakeHeapSafe ( src -> localsplus [i ]) ;
158170    }
159-     // Don't leave a dangling pointer to the old frame when creating generators 
160-     // and coroutines: 
161-     dest -> previous  =  NULL ;
162171}
163172
164173#ifdef  Py_GIL_DISABLED 
@@ -393,7 +402,7 @@ _PyFrame_PushTrampolineUnchecked(PyThreadState *tstate, PyCodeObject *code, int
393402
394403PyAPI_FUNC (_PyInterpreterFrame  * )
395404_PyEvalFramePushAndInit (PyThreadState  * tstate , _PyStackRef  func ,
396-                         PyObject  * locals , _PyStackRef  const *   args ,
405+                         PyObject  * locals , _PyStackRef  const   * args ,
397406                        size_t  argcount , PyObject  * kwnames ,
398407                        _PyInterpreterFrame  * previous );
399408
0 commit comments