diff --git a/ChangeLog b/ChangeLog index 2a86630a40..75c49e478e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon May 23 12:47:09 2016 Nobuyoshi Nakada + + * 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 * ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): consider 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; }