[前][次][番号順一覧][スレッド一覧]

ruby-changes:64399

From: Yusuke <ko1@a...>
Date: Mon, 21 Dec 2020 11:41:03 +0900 (JST)
Subject: [ruby-changes:64399] eee93bc933 (master): eval_error.c: fix off-by-one error for --backtrace-limit

https://git.ruby-lang.org/ruby.git/commit/?id=eee93bc933

From eee93bc9330cb069abb679a0a0d48a49b10f6a4e Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Mon, 21 Dec 2020 11:33:22 +0900
Subject: eval_error.c: fix off-by-one error for --backtrace-limit

https://bugs.ruby-lang.org/issues/17413

diff --git a/eval_error.c b/eval_error.c
index 1e6579c..841275e 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -253,9 +253,9 @@ print_backtrace(const VALUE eclass, const VALUE errat, const VALUE str, int reve https://github.com/ruby/ruby/blob/trunk/eval_error.c#L253
         }
 
         // skip for explicit limit
-        if (rb_backtrace_length_limit >= 0 && len > rb_backtrace_length_limit + 1) {
+        if (rb_backtrace_length_limit >= 0 && len > rb_backtrace_length_limit + 2) {
             skip_start = rb_backtrace_length_limit + 1;
-            skip_len = len - rb_backtrace_length_limit;
+            skip_len = len - skip_start;
         }
 
 	for (i = 1; i < len; i++) {
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]