Index: generic/xotclStack85.c =================================================================== diff -u -rdc6c71950983c8fc6c220a751e3e0e3f79b5e10b -rec939a7b02581cdfc2a0c6fdf9393b2c83030207 --- generic/xotclStack85.c (.../xotclStack85.c) (revision dc6c71950983c8fc6c220a751e3e0e3f79b5e10b) +++ generic/xotclStack85.c (.../xotclStack85.c) (revision ec939a7b02581cdfc2a0c6fdf9393b2c83030207) @@ -360,6 +360,26 @@ */ obj->flags &= ~XOTCL_DESTROY_CALLED; } + +/* + * Pop any callstack entry that is still alive (e.g. + * if "exit" is called and we were jumping out of the + * callframe + */ +void CallStackPopAll(Tcl_Interp *interp) { + + while (1) { + Tcl_CallFrame *framePtr = Tcl_Interp_framePtr(interp); + if (!framePtr) break; + if (Tcl_CallFrame_level(framePtr) == 0) break; + if (Tcl_CallFrame_isProcCallFrame(framePtr) & (FRAME_IS_XOTCL_METHOD|FRAME_IS_XOTCL_CMETHOD)) { + /* free the call stack content; for now, we pop it from the allocation stack */ + CallStackPop(interp); + } + /* pop the Tcl frame */ + Tcl_PopCallFrame(interp); + } +} #endif /* TCL85STACK */