mruby-class-ext: fix crash in module comparison with invalid types

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-14 08:22:41 +09:00
parent 4f52868923
commit 4c1b2a59bd
+2 -1
View File
@@ -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");
}