summaryrefslogtreecommitdiff
path: root/internal/class.h
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 /internal/class.h
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 'internal/class.h')
-rw-r--r--internal/class.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/internal/class.h b/internal/class.h
index 15530b8842..4a3e0afafb 100644
--- a/internal/class.h
+++ b/internal/class.h
@@ -667,7 +667,8 @@ RCLASS_ALLOCATOR(VALUE klass)
static inline void
RCLASS_SET_ALLOCATOR(VALUE klass, rb_alloc_func_t allocator)
{
- assert(!RCLASS_SINGLETON_P(klass));
+ RUBY_ASSERT(RB_TYPE_P(klass, T_CLASS));
+ RUBY_ASSERT(!RCLASS_SINGLETON_P(klass));
RCLASS_EXT_PRIME(klass)->as.class.allocator = allocator; // Allocator is set only on the initial definition
}