From 89830296eb1615019e1b307bf92d841357c2f33f Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 24 Dec 2022 19:20:37 +0900 Subject: [PATCH] numeric.c (int_round): `n` may not be a bigint `mrb_bint_add()` expects its first operand to be a bigint. --- src/numeric.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/numeric.c b/src/numeric.c index e5e77ed5f..a671eeba7 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1688,6 +1688,7 @@ int_round(mrb_state *mrb, mrb_value x) mrb_value h = mrb_bigint_p(f) ? mrb_bint_rshift(mrb, f, 1) : mrb_int_value(mrb, mrb_integer(f)>>1); mrb_int cmp = mrb_bigint_p(r) ? mrb_bint_cmp(mrb, r, h) : (mrb_integer(r) - mrb_integer(h)); if ((cmp > 0) || (cmp == 0 && mrb_bint_cmp(mrb, x, mrb_fixnum_value(0)) > 0)) { + n = mrb_as_bint(mrb, n); n = mrb_bint_add(mrb, n, f); } return n;