Skip to content

Commit 22e7e24

Browse files
fredcallawayKristofferC
authored andcommitted
while loop -> for loop in _simplify_include_frames (fixes #41566) (#41622)
* while loop -> for loop in _simplify_include_frames (fixes #41566) prevents the possibility of a bounds error when i = 0 (cherry picked from commit ed4f316)
1 parent c6a135d commit 22e7e24

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

base/errorshow.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -788,10 +788,9 @@ end
788788
# For improved user experience, filter out frames for include() implementation
789789
# - see #33065. See also #35371 for extended discussion of internal frames.
790790
function _simplify_include_frames(trace)
791-
i = length(trace)
792-
kept_frames = trues(i)
791+
kept_frames = trues(length(trace))
793792
first_ignored = nothing
794-
while i >= 1
793+
for i in length(trace):-1:1
795794
frame::StackFrame, _ = trace[i]
796795
mod = parentmodule(frame)
797796
if first_ignored === nothing
@@ -813,10 +812,9 @@ function _simplify_include_frames(trace)
813812
first_ignored = nothing
814813
end
815814
end
816-
i -= 1
817815
end
818816
if first_ignored !== nothing
819-
kept_frames[i:first_ignored] .= false
817+
kept_frames[1:first_ignored] .= false
820818
end
821819
return trace[kept_frames]
822820
end

0 commit comments

Comments
 (0)