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

ruby-changes:43050

From: nobu <ko1@a...>
Date: Mon, 23 May 2016 12:47:16 +0900 (JST)
Subject: [ruby-changes:43050] nobu:r55124 (trunk): fatal error if variable argument length mismatch

nobu	2016-05-23 12:47:11 +0900 (Mon, 23 May 2016)

  New Revision: 55124

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

  Log:
    fatal error if variable argument length mismatch
    
    * include/ruby/ruby.h (rb_scan_args0): raise fatal error if
      variable argument length does not match, it is a bug in the code
      which uses rb_scan_args, not a runtime error.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/ruby.h
Index: include/ruby/ruby.h
===================================================================
--- include/ruby/ruby.h	(revision 55123)
+++ include/ruby/ruby.h	(revision 55124)
@@ -2203,6 +2203,12 @@ rb_scan_args0(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2203
     }
     n_mand = n_lead + n_trail;
 
+    vari = n_mand + n_opt + f_var + f_hash + f_block;
+    if (vari != varc) {
+	rb_fatal("variable argument length doesn't match* %d %d", vari, varc);
+    }
+    vari = 0;
+
     if (argc < n_mand)
 	goto argc_error;
 
@@ -2282,9 +2288,6 @@ rb_scan_args0(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L2288
       argc_error:
 	rb_error_arity(argc, n_mand, f_var ? UNLIMITED_ARGUMENTS : n_mand + n_opt);
     }
-    if (vari != varc) {
-	rb_raise(rb_eRuntimeError, "variable argument length doesn't match* %d %d", vari, varc);
-    }
 
     return argc;
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55123)
+++ ChangeLog	(revision 55124)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May 23 12:47:09 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* include/ruby/ruby.h (rb_scan_args0): raise fatal error if
+	  variable argument length does not match, it is a bug in the code
+	  which uses rb_scan_args, not a runtime error.
+
 Mon May 23 12:30:29 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): consider

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

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