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:
Yukihiro "Matz" Matsumoto
2025-11-18 10:14:13 +09:00
parent 8113c0d24a
commit 281b38c0b6
+2
View File
@@ -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)) {