diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-02 00:22:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-01-02 00:22:46 +0000 |
commit | 03b8cb95481fce36c0460e1c90564d08249312fe (patch) | |
tree | 348cb29941ac26a9827a3fc1a88916461a081183 | |
parent | 42361548d8669fe5ae8e3625aabc0d34c3513b68 (diff) | |
download | ruby-03b8cb95481fce36c0460e1c90564d08249312fe.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
-rw-r--r-- | object.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -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); |