summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-21 09:40:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-21 09:40:58 +0000
commit1bcee938d5f4a0a70d492c1c1c13ec29f24980ea (patch)
tree293aa767120f08607fe842751da29aa0611b35ad /class.c
parenta7f6b862f0ddfea4ab9f6587bc666d978a8f41a4 (diff)
* gc.c (internal_object_p): should not expose singleton classes
without a metaclass. [Bug #11740] * class.c (rb_singleton_class_has_metaclass_p): added. * test/ruby/test_class.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/class.c b/class.c
index f95890b..fdebee8 100644
--- a/class.c
+++ b/class.c
@@ -442,6 +442,12 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
*/
#define META_CLASS_OF_CLASS_CLASS_P(k) (METACLASS_OF(k) == (k))
+int
+rb_singleton_class_has_metaclass_p(VALUE sklass)
+{
+ return rb_attr_get(METACLASS_OF(sklass), id_attached) == sklass;
+}
+
/*!
* whether k has a metaclass
* @retval 1 if \a k has a metaclass
@@ -449,7 +455,13 @@ rb_singleton_class_attached(VALUE klass, VALUE obj)
*/
#define HAVE_METACLASS_P(k) \
(FL_TEST(METACLASS_OF(k), FL_SINGLETON) && \
- rb_ivar_get(METACLASS_OF(k), id_attached) == (k))
+ rb_singleton_class_has_metaclass_p(k))
+
+int
+rb_class_has_metaclass_p(VALUE klass)
+{
+ return HAVE_METACLASS_P(klass);
+}
/*!
* ensures \a klass belongs to its own eigenclass.