summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2025-05-19 17:37:25 -0700
committerJohn Hawthorn <[email protected]>2025-05-23 10:33:48 -0700
commit05cdcfcefd7854ee2601ff876a9ddb22b5feed81 (patch)
tree49f13a11dd6e622084f4d97ec71276a8d1a5082f /class.c
parente01e89f55c82be8db5d8ccbf305ee38e3769e582 (diff)
Only call RCLASS_SET_ALLOCATOR on T_CLASS objects
It's invalid to set an allocator on a T_ICLASS or T_MODULE, as those use the other fields from the union.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13416
Diffstat (limited to 'class.c')
-rw-r--r--class.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/class.c b/class.c
index ba57d8a39d..c31d1a9be7 100644
--- a/class.c
+++ b/class.c
@@ -700,7 +700,6 @@ class_alloc(VALUE flags, VALUE klass)
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
RCLASS_SET_REFINED_CLASS((VALUE)obj, Qnil);
- RCLASS_SET_ALLOCATOR((VALUE)obj, 0);
RCLASS_SET_SUBCLASSES((VALUE)obj, anchor);
@@ -1044,7 +1043,9 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig));
rb_singleton_class_attached(METACLASS_OF(clone), (VALUE)clone);
}
- RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig));
+ if (BUILTIN_TYPE(clone) == T_CLASS) {
+ RCLASS_SET_ALLOCATOR(clone, RCLASS_ALLOCATOR(orig));
+ }
copy_tables(clone, orig);
if (RCLASS_M_TBL(orig)) {
struct clone_method_arg arg;
@@ -1085,7 +1086,6 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
rb_class_set_super(prev_clone_p, clone_p);
prev_clone_p = clone_p;
RCLASS_SET_CONST_TBL(clone_p, RCLASS_CONST_TBL(p), false);
- RCLASS_SET_ALLOCATOR(clone_p, RCLASS_ALLOCATOR(p));
if (RB_TYPE_P(clone, T_CLASS)) {
RCLASS_SET_INCLUDER(clone_p, clone);
}