diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-23 03:47:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-23 03:47:11 +0000 |
commit | 14c43e2be6d356fa49ebd39885786bf6d3c6e4c1 (patch) | |
tree | 400f9f17b77411e5f5d789431dad0cf927f9496c /include | |
parent | 4a574f7ad985d7e5d1d1596b7632e4db8620e65b (diff) | |
download | ruby-14c43e2be6d356fa49ebd39885786bf6d3c6e4c1.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.h | 9 |
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; } |