mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
bigint.c: add missing mrb_as_bint calls in mod and rem
mrb_bint_mod() and mrb_bint_rem() were missing conversion of the first operand x to bigint before calling bint_as_mpz(). this caused crashes when x was not already a bigint. added mrb_as_bint(mrb, x) calls to ensure both operands are properly converted. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3257,6 +3257,7 @@ mrb_bint_mod(mrb_state *mrb, mrb_value x, mrb_value y)
|
||||
mrb_int_zerodiv(mrb);
|
||||
}
|
||||
mpz_t a, b, z;
|
||||
x = mrb_as_bint(mrb, x);
|
||||
y = mrb_as_bint(mrb, y);
|
||||
bint_as_mpz(RBIGINT(y), &b);
|
||||
if (zero_p(&b) || uzero_p(&b)) {
|
||||
@@ -3279,6 +3280,7 @@ mrb_bint_rem(mrb_state *mrb, mrb_value x, mrb_value y)
|
||||
mrb_int_zerodiv(mrb);
|
||||
}
|
||||
mpz_t a, b, z;
|
||||
x = mrb_as_bint(mrb, x);
|
||||
y = mrb_as_bint(mrb, y);
|
||||
bint_as_mpz(RBIGINT(y), &b);
|
||||
if (zero_p(&b) || uzero_p(&b)) {
|
||||
|
||||
Reference in New Issue
Block a user