summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-12-06 12:06:25 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2022-12-08 15:58:26 -0500
commitbb8afd7265af41a75e8889774aa26f157f146380 (patch)
treeb007884bac61642c1f063130bd9884bbeab5e821 /class.c
parent47a5b34aba514fd075664b4cf0e95e0f7f26609f (diff)
downloadruby-bb8afd7265af41a75e8889774aa26f157f146380.tar.gz
Freeze singleton class, not its origin
Previously, when we froze an object, we froze `RCLASS_ORIGIN(object.singleton_class)`, which didn't freeze `object.singleton_class` when it has some prepended modules. Origin iclass are internal objects and users can't interact with them through Kernel#freeze?, Kernel#freeze, or any mutation method that checks the frozen status. So we shouldn't touch the origin iclasses when the frozen status should be visible. [Bug #19169]
Diffstat (limited to 'class.c')
-rw-r--r--class.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/class.c b/class.c
index 87ebabef32..55bc761ebe 100644
--- a/class.c
+++ b/class.c
@@ -2148,7 +2148,7 @@ rb_freeze_singleton_class(VALUE x)
/* should not propagate to meta-meta-class, and so on */
if (!(RBASIC(x)->flags & FL_SINGLETON)) {
VALUE klass = RBASIC_CLASS(x);
- if (klass && (klass = RCLASS_ORIGIN(klass)) != 0 &&
+ if (klass && // no class when hidden from ObjectSpace
FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) {
OBJ_FREEZE_RAW(klass);
}