From 87d8cb19e4eed905b93d39554ea9a2a1012f6668 Mon Sep 17 00:00:00 2001 From: FlandreScarlet Date: Thu, 23 Jun 2022 14:07:08 +0200 Subject: std.debug: fix ConfigurableTrace.dump OOB The for-loop in dump() would index out of bounds if `t.index` is greater than size, because `end` is the maximum of `t.index` and `size` rather than the minimum. --- lib/std/debug.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/std/debug.zig') diff --git a/lib/std/debug.zig b/lib/std/debug.zig index ba1f509e6c..af5d54ae62 100644 --- a/lib/std/debug.zig +++ b/lib/std/debug.zig @@ -1999,7 +1999,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize const tty_config = detectTTYConfig(); const stderr = io.getStdErr().writer(); - const end = @maximum(t.index, size); + const end = @minimum(t.index, size); const debug_info = getSelfDebugInfo() catch |err| { stderr.print( "Unable to dump stack trace: Unable to open debug info: {s}\n", -- cgit v1.2.3