From 4c1b2a59bd0c3ea72cf5b1648f89c619fa4e2f8f Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 14 Oct 2025 08:22:41 +0900 Subject: [PATCH] mruby-class-ext: fix crash in module comparison with invalid types Co-authored-by: Claude --- mrbgems/mruby-class-ext/src/class.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mrbgems/mruby-class-ext/src/class.c b/mrbgems/mruby-class-ext/src/class.c index 0f3a57e5b..d68c3fe10 100644 --- a/mrbgems/mruby-class-ext/src/class.c +++ b/mrbgems/mruby-class-ext/src/class.c @@ -214,7 +214,8 @@ is_ancestor(struct RClass *klass, struct RClass *super) static mrb_value mod_compare_hierarchy(mrb_state *mrb, mrb_value self, mrb_value other) { - if (!mrb_class_p(other) && !mrb_module_p(other) && !mrb_iclass_p(other)) { + if ((!mrb_class_p(self) && !mrb_module_p(self) && !mrb_iclass_p(self)) || + (!mrb_class_p(other) && !mrb_module_p(other) && !mrb_iclass_p(other))) { mrb_raise(mrb, E_TYPE_ERROR, "compared with non class/module"); }