ruby-changes:25205
From: nobu <ko1@a...>
Date: Thu, 18 Oct 2012 16:44:21 +0900 (JST)
Subject: [ruby-changes:25205] nobu:r37257 (trunk): vm_method.c: check arity earlier
nobu 2012-10-18 16:44:09 +0900 (Thu, 18 Oct 2012) New Revision: 37257 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37257 Log: vm_method.c: check arity earlier * vm_method.c (rb_add_method_cfunc, rb_add_method_cfunc_frameless): check arity earlier at definition time. Modified files: trunk/ChangeLog trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 37256) +++ ChangeLog (revision 37257) @@ -1,3 +1,8 @@ +Thu Oct 18 16:44:07 2012 Nobuyoshi Nakada <nobu@r...> + + * vm_method.c (rb_add_method_cfunc, rb_add_method_cfunc_frameless): + check arity earlier at definition time. + Thu Oct 18 15:11:31 2012 Koichi Sasada <ko1@a...> * vm_insnhelper.c: add `inline' keyword to several functions. Index: vm_method.c =================================================================== --- vm_method.c (revision 37256) +++ vm_method.c (revision 37257) @@ -84,6 +84,7 @@ void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex) { + if (argc < -2 || 15 < argc) rb_raise(rb_eArgError, "arity out of range: %d for -2..15", argc); if (func != rb_f_notimplement) { rb_method_cfunc_t opt; opt.func = func; @@ -98,6 +99,7 @@ void rb_add_method_cfunc_frameless(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex) { + if (argc < 0 || 1 < argc) rb_raise(rb_eArgError, "arity out of range: %d for 0..1", argc); if (func != rb_f_notimplement) { rb_method_cfunc_t opt; opt.func = func; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/