summaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-19 05:56:09 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-08-19 05:56:09 +0000
commit2753f846938e5edfd164de9d1c72d5bce7c593ec (patch)
tree15aff53955adad0d278851c21030857a07bd2f5f /object.c
parent815106b114792039d8362f3cfc683d5b61d28ec5 (diff)
downloadruby-2753f846938e5edfd164de9d1c72d5bce7c593ec.tar.gz
ruby-2753f846938e5edfd164de9d1c72d5bce7c593ec.tar.xz
ruby-2753f846938e5edfd164de9d1c72d5bce7c593ec.zip
* array.c (sort_2): *a - *b may overflow.
* array.c (ary_new): len*sizeof(VALUE) may be a positive value. * array.c (rb_ary_initialize): ditto. * object.c (rb_class_allocate_instance): move singleton class check from rb_obj_alloc(). * re.c (rb_reg_initialize): should not modify frozen Regexp. * ext/tcltklib/tcltklib.c (ip_init): allocation framework. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r--object.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/object.c b/object.c
index 13ae657ee..7523b7aa3 100644
--- a/object.c
+++ b/object.c
@@ -667,12 +667,7 @@ VALUE
rb_obj_alloc(klass)
VALUE klass;
{
- VALUE obj;
-
- if (FL_TEST(klass, FL_SINGLETON)) {
- rb_raise(rb_eTypeError, "can't create instance of virtual class");
- }
- obj = rb_funcall(klass, alloc, 0, 0);
+ VALUE obj = rb_funcall(klass, alloc, 0, 0);
if (rb_obj_class(obj) != rb_class_real(klass)) {
rb_raise(rb_eTypeError, "wrong instance allocation");
@@ -684,6 +679,9 @@ static VALUE
rb_class_allocate_instance(klass)
VALUE klass;
{
+ if (FL_TEST(klass, FL_SINGLETON)) {
+ rb_raise(rb_eTypeError, "can't create instance of virtual class");
+ }
if (rb_frame_last_func() != alloc) {
return rb_obj_alloc(klass);
}