From 281b38c0b6b3fe7802efec2e721cba39fec48588 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 18 Nov 2025 10:14:13 +0900 Subject: [PATCH] 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 --- mrbgems/mruby-bigint/core/bigint.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mrbgems/mruby-bigint/core/bigint.c b/mrbgems/mruby-bigint/core/bigint.c index 56952fa4d..bb5fc918f 100644 --- a/mrbgems/mruby-bigint/core/bigint.c +++ b/mrbgems/mruby-bigint/core/bigint.c @@ -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)) {