summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-02-29 04:20:13 +0900
committerKoichi Sasada <ko1@atdot.net>2020-02-29 04:22:17 +0900
commitb3983c68dd74ba013f7ac41a3df67ad2e4fdcc23 (patch)
treeaa770a756c1f5e7f301c76ab9ae20c8aa777cbd7 /ext
parentb621c9abd167ac0641ac81b0a233d0f3d6892bea (diff)
should not expose hidden object.
Hidden object (T_CLASS) can be exposed (BUG). Also rename rb_mInternalObjectWrapper to rb_cInternalObjectWrapper because it is a class.
Diffstat (limited to 'ext')
-rw-r--r--ext/objspace/objspace.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index dc1a0cb..f470f74 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -665,12 +665,12 @@ static const rb_data_type_t iow_data_type = {
0, 0, RUBY_TYPED_FREE_IMMEDIATELY
};
-static VALUE rb_mInternalObjectWrapper;
+static VALUE rb_cInternalObjectWrapper;
static VALUE
iow_newobj(VALUE obj)
{
- return TypedData_Wrap_Struct(rb_mInternalObjectWrapper, &iow_data_type, (void *)obj);
+ return TypedData_Wrap_Struct(rb_cInternalObjectWrapper, &iow_data_type, (void *)obj);
}
/* Returns the type of the internal object. */
@@ -866,7 +866,8 @@ wrap_klass_iow(VALUE klass)
if (!RTEST(klass)) {
return Qnil;
}
- else if (RB_TYPE_P(klass, T_ICLASS)) {
+ else if (RB_TYPE_P(klass, T_ICLASS) ||
+ CLASS_OF(klass) == Qfalse /* hidden object */) {
return iow_newobj(klass);
}
else {
@@ -979,10 +980,10 @@ Init_objspace(void)
*
* You can use the #type method to check the type of the internal object.
*/
- rb_mInternalObjectWrapper = rb_define_class_under(rb_mObjSpace, "InternalObjectWrapper", rb_cObject);
- rb_define_method(rb_mInternalObjectWrapper, "type", iow_type, 0);
- rb_define_method(rb_mInternalObjectWrapper, "inspect", iow_inspect, 0);
- rb_define_method(rb_mInternalObjectWrapper, "internal_object_id", iow_internal_object_id, 0);
+ rb_cInternalObjectWrapper = rb_define_class_under(rb_mObjSpace, "InternalObjectWrapper", rb_cObject);
+ rb_define_method(rb_cInternalObjectWrapper, "type", iow_type, 0);
+ rb_define_method(rb_cInternalObjectWrapper, "inspect", iow_inspect, 0);
+ rb_define_method(rb_cInternalObjectWrapper, "internal_object_id", iow_internal_object_id, 0);
Init_object_tracing(rb_mObjSpace);
Init_objspace_dump(rb_mObjSpace);