summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-31 13:15:52 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-31 13:15:52 (GMT)
commitc5f4c44f82905bef60d49254e250ba55e0e8f205 (patch)
tree5ff0bf11a8fac779508a032d7e944c9b7ae52179 /error.c
parent487efc80b0a2b97813626361b7962f77b6638d92 (diff)
error.c: limit depth
* error.c (rb_warn_m): limit backtrace depth to reduce objects to be created but not used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/error.c b/error.c
index 7ec59cd..aba99c9 100644
--- a/error.c
+++ b/error.c
@@ -342,12 +342,14 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc)
uplevel = Qnil;
}
else if (!NIL_P(uplevel)) {
+ VALUE args[2];
long lev = NUM2LONG(uplevel);
if (lev < 0) {
rb_raise(rb_eArgError, "negative level (%ld)", lev);
}
- uplevel = LONG2NUM(lev + 1);
- uplevel = rb_vm_thread_backtrace_locations(1, &uplevel, GET_THREAD()->self);
+ args[0] = LONG2NUM(lev + 1);
+ args[1] = INT2FIX(1);
+ uplevel = rb_vm_thread_backtrace_locations(2, args, GET_THREAD()->self);
if (!NIL_P(uplevel)) {
uplevel = rb_ary_entry(uplevel, 0);
}
@@ -360,7 +362,7 @@ rb_warn_m(int argc, VALUE *argv, VALUE exc)
else {
VALUE path;
path = rb_funcall(uplevel, rb_intern("path"), 0);
- str = rb_sprintf("%s:%li: warning: ",
+ str = rb_sprintf("%s:%ld: warning: ",
rb_string_value_ptr(&path),
NUM2LONG(rb_funcall(uplevel, rb_intern("lineno"), 0)));
}