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

ruby-changes:49411

From: nobu <ko1@a...>
Date: Sun, 31 Dec 2017 22:15:57 +0900 (JST)
Subject: [ruby-changes:49411] nobu:r61527 (trunk): error.c: limit depth

nobu	2017-12-31 22:15:52 +0900 (Sun, 31 Dec 2017)

  New Revision: 61527

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61527

  Log:
    error.c: limit depth
    
    * error.c (rb_warn_m): limit backtrace depth to reduce objects to
      be created but not used.

  Modified files:
    trunk/error.c
Index: error.c
===================================================================
--- error.c	(revision 61526)
+++ error.c	(revision 61527)
@@ -342,12 +342,14 @@ rb_warn_m(int argc, VALUE *argv, VALUE e https://github.com/ruby/ruby/blob/trunk/error.c#L342
 		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 e https://github.com/ruby/ruby/blob/trunk/error.c#L362
 	    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)));
 	    }

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

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