From 3d272b0fc822f5c2e9c716377b7fcecf15426b27 Mon Sep 17 00:00:00 2001 From: Jean byroot Boussier Date: Thu, 1 Dec 2022 23:32:41 +0100 Subject: Module#remove_method: Check frozen on the right object Previously, the frozen check happened on `RCLASS_ORIGIN(self)`, which can return an iclass. The frozen check is supposed to respond to objects that users can call methods on while iclasses are hidden from users. Other mutation methods like Module#{define_method,alias_method,public} don't do this. Check frozen status on the module itself. Fixes [Bug #19164] and [Bug #19166]. Co-authored-by: Alan Wu --- vm_method.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vm_method.c') diff --git a/vm_method.c b/vm_method.c index f1c50b9300..2c5ccdb3d7 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1541,8 +1541,8 @@ remove_method(VALUE klass, ID mid) rb_method_entry_t *me = 0; VALUE self = klass; - klass = RCLASS_ORIGIN(klass); rb_class_modify_check(klass); + klass = RCLASS_ORIGIN(klass); if (mid == object_id || mid == id__send__ || mid == idInitialize) { rb_warn("removing `%s' may cause serious problems", rb_id2name(mid)); } -- cgit v1.2.1