Skip to content

Commit ce7d29b

Browse files
committed
Guard against invalid frame indexing in backtrace
1 parent e540f79 commit ce7d29b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

trepan/processor/print.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ def prefix_for_filename(deparsed_text: str) -> str:
149149
remapped_file = None
150150
source_text = None
151151
eval_kind = None
152-
while i_stack >= 0 and len(proc_obj.stack) > 0:
152+
i_stack = min(i_stack, len(proc_obj.stack) - 1)
153+
while i_stack >= 0:
153154
frame, lineno = proc_obj.stack[i_stack]
154155

155156
# Before starting a program a location for a module with
@@ -253,7 +254,7 @@ def prefix_for_filename(deparsed_text: str) -> str:
253254
# into the corresponding line of the tempfile
254255
co = proc_obj.curframe.f_code
255256
tempdir = proc_obj.settings("tempdir")
256-
temp_filename, name_for_code = deparse_and_cache(
257+
temp_filename, _ = deparse_and_cache(
257258
co, proc_obj.errmsg, tempdir=tempdir
258259
)
259260
lineno = 1

0 commit comments

Comments
 (0)