mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user