ruby-changes:45176
From: nobu <ko1@a...>
Date: Mon, 2 Jan 2017 09:03:32 +0900 (JST)
Subject: [ruby-changes:45176] nobu:r57249 (trunk): object.c: rb_class_s_new
nobu 2017-01-02 09:03:28 +0900 (Mon, 02 Jan 2017) New Revision: 57249 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57249 Log: 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] Modified files: trunk/object.c Index: object.c =================================================================== --- object.c (revision 57248) +++ object.c (revision 57249) @@ -1886,8 +1886,8 @@ rb_class_allocate_instance(VALUE klass) https://github.com/ruby/ruby/blob/trunk/object.c#L1886 * */ -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 VA https://github.com/ruby/ruby/blob/trunk/object.c#L1897 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) https://github.com/ruby/ruby/blob/trunk/object.c#L3587 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); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/