numeric.c: fix SEGV in int_divmod when argument is not numeric

int_divmod passed an integer mrb_value directly to flo_divmod, which
used mrb_float() to extract the value. In word boxing mode, this caused
a misaligned pointer dereference. Use mrb_ensure_float_type() to safely
convert the integer to float before passing to flo_divmod.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-02-19 20:31:45 +09:00
parent a1ee420aea
commit a208440c4f
+1 -1
View File
@@ -1263,7 +1263,7 @@ int_divmod(mrb_state *mrb, mrb_value x)
#ifdef MRB_NO_FLOAT
mrb_raise(mrb, E_TYPE_ERROR, "non integer divmod");
#else
return flo_divmod(mrb, x);
return flo_divmod(mrb, mrb_ensure_float_type(mrb, x));
#endif
}