diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-18 07:44:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-18 07:44:09 +0000 |
commit | 6be52625b25ac334f182a7814c7c0590c5a0bc16 (patch) | |
tree | 5fdc68a76a8416b37b819cde5d846b212f9a01f3 | |
parent | 60f949e1013bf22e5392587ef725888f82834e48 (diff) | |
download | ruby-6be52625b25ac334f182a7814c7c0590c5a0bc16.tar.gz |
vm_method.c: check arity earlier
* vm_method.c (rb_add_method_cfunc, rb_add_method_cfunc_frameless):
check arity earlier at definition time.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37257 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | vm_method.c | 2 |
2 files changed, 7 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Thu Oct 18 16:44:07 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@atdot.net> * vm_insnhelper.c: add `inline' keyword to several functions. diff --git a/vm_method.c b/vm_method.c index 095af7643b..058b03dac6 100644 --- a/vm_method.c +++ b/vm_method.c @@ -84,6 +84,7 @@ rb_define_notimplement_method_id(VALUE mod, ID id, rb_method_flag_t noex) 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 @@ rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_me 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; |