aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-02 00:03:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-02 00:03:28 +0000
commit472348fe8bb5b7e3b43dae28ae695e9648f14ca1 (patch)
treeee106ea540ae75838012542b44c28a965c9ecf8b /object.c
parent42d1ad91daaf51e80f41b83603b9d10869d9e25b (diff)
downloadruby-472348fe8bb5b7e3b43dae28ae695e9648f14ca1.tar.gz
object.c: rb_class_s_new
* object.c (rb_class_new_instance): add pathological check of klass for extension libraries which do not check given arguments properly. [ruby-core:78934] [Bug #13093] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/object.c b/object.c
index 5f0055fb5a..67d23ef830 100644
--- a/object.c
+++ b/object.c
@@ -1886,8 +1886,8 @@ rb_class_allocate_instance(VALUE klass)
*
*/
-VALUE
-rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
+static VALUE
+rb_class_s_new(int argc, const VALUE *argv, VALUE klass)
{
VALUE obj;
@@ -1897,6 +1897,13 @@ rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
return obj;
}
+VALUE
+rb_class_new_instance(int argc, const VALUE *argv, VALUE klass)
+{
+ Check_Type(klass, T_CLASS);
+ return rb_class_s_new(argc, argv, klass);
+}
+
/*
* call-seq:
* class.superclass -> a_super_class or nil
@@ -3580,7 +3587,7 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
- rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
+ rb_define_method(rb_cClass, "new", rb_class_s_new, -1);
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
rb_define_alloc_func(rb_cClass, rb_class_s_alloc);