aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-02 00:22:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-02 00:22:46 +0000
commitbf6c801cb962691e5c241d5201d7af9215e1594c (patch)
tree348cb29941ac26a9827a3fc1a88916461a081183 /object.c
parent472348fe8bb5b7e3b43dae28ae695e9648f14ca1 (diff)
downloadruby-bf6c801cb962691e5c241d5201d7af9215e1594c.tar.gz
object.c: rb_class_alloc
* object.c (rb_obj_alloc): 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@57250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/object.c b/object.c
index 67d23ef830..3a9a556947 100644
--- a/object.c
+++ b/object.c
@@ -1840,8 +1840,8 @@ rb_undefined_alloc(VALUE klass)
*
*/
-VALUE
-rb_obj_alloc(VALUE klass)
+static VALUE
+rb_class_alloc(VALUE klass)
{
VALUE obj;
rb_alloc_func_t allocator;
@@ -1867,6 +1867,13 @@ rb_obj_alloc(VALUE klass)
return obj;
}
+VALUE
+rb_obj_alloc(VALUE klass)
+{
+ Check_Type(klass, T_CLASS);
+ return rb_class_alloc(klass);
+}
+
static VALUE
rb_class_allocate_instance(VALUE klass)
{
@@ -1891,7 +1898,7 @@ rb_class_s_new(int argc, const VALUE *argv, VALUE klass)
{
VALUE obj;
- obj = rb_obj_alloc(klass);
+ obj = rb_class_alloc(klass);
rb_obj_call_init(obj, argc, argv);
return obj;
@@ -3586,7 +3593,7 @@ InitVM_Object(void)
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
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, "allocate", rb_class_alloc, 0);
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);