aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-23 03:47:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-23 03:47:11 +0000
commit73aaf5d569d08ac608e0fd4af93e4cbd1d34a561 (patch)
tree400f9f17b77411e5f5d789431dad0cf927f9496c /include
parent172abd7255d26766c1fb78e7d8ee70ce314b7e2f (diff)
downloadruby-73aaf5d569d08ac608e0fd4af93e4cbd1d34a561.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/ruby.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index fe2297c567..10c220d3a2 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -2203,6 +2203,12 @@ rb_scan_args0(int argc, const VALUE *argv, const char *fmt, int varc, VALUE *var
}
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 *argv, const char *fmt, int varc, VALUE *var
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;
}