From 537494be8151ed09a6afb6d07f752ca542f79fa0 Mon Sep 17 00:00:00 2001 From: sebres Date: Tue, 2 Jul 2024 14:36:59 +0000 Subject: info frame: restored return {type precompiled} in case of no frame information; see [0de6c1d79cfba2ea] for description --- generic/tclCmdIL.c | 16 +++++++++------- tests/info.test | 8 +++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index 877f94e..b4f821f 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -1211,9 +1211,6 @@ InfoFrameCmd( } framePtr = iPtr->cmdFramePtr; - if (!framePtr) { - goto levelError; - } while (++level <= 0) { framePtr = framePtr->nextPtr; if (!framePtr) { @@ -1282,9 +1279,14 @@ TclInfoFrame( static const char *const typeString[TCL_LOCATION_LAST] = { "eval", "eval", "eval", "precompiled", "source", "proc" }; - Proc *procPtr = framePtr->framePtr ? framePtr->framePtr->procPtr : NULL; + Proc *procPtr = NULL; int needsFree = -1; + if (!framePtr) { + goto precompiled; + } + procPtr = framePtr->framePtr ? framePtr->framePtr->procPtr : NULL; + /* * Pull the information and construct the dictionary to return, as list. * Regarding use of the CmdFrame fields see tclInt.h, and its definition. @@ -1312,11 +1314,11 @@ TclInfoFrame( break; case TCL_LOCATION_PREBC: + precompiled: /* * Precompiled. Result contains the type as signal, nothing else. */ - - ADD_PAIR("type", Tcl_NewStringObj(typeString[framePtr->type], -1)); + ADD_PAIR("type", Tcl_NewStringObj(typeString[TCL_LOCATION_PREBC], -1)); break; case TCL_LOCATION_BC: { @@ -1431,7 +1433,7 @@ TclInfoFrame( * _visible_ CallFrame. */ - if ((framePtr->framePtr != NULL) && (iPtr->varFramePtr != NULL)) { + if (framePtr && (framePtr->framePtr != NULL) && (iPtr->varFramePtr != NULL)) { CallFrame *current = framePtr->framePtr; CallFrame *top = iPtr->varFramePtr; CallFrame *idx; diff --git a/tests/info.test b/tests/info.test index 17c114b..0921466 100644 --- a/tests/info.test +++ b/tests/info.test @@ -2420,12 +2420,14 @@ test info-40.0 {Bug 0de6c1d79c crash} -setup { child hide info } -body { list [child invokehidden info frame] \ - [catch {child invokehidden info frame 0} msg] $msg \ - [catch {child invokehidden info frame 1} msg] $msg + [child invokehidden info frame 0] \ + [child invokehidden info frame 1] \ + [catch {child invokehidden info frame -1} msg] $msg \ + [catch {child invokehidden info frame 2} msg] $msg } -cleanup { interp delete child unset -nocomplain msg -} -result {1 1 {bad level "0"} 1 {bad level "1"}} +} -result {1 {type precompiled} {type precompiled} 1 {bad level "-1"} 1 {bad level "2"}} # cleanup catch {namespace delete test_ns_info1 test_ns_info2} -- cgit v0.12