mruby-rational (int_lshift): check before actual left bit shift

This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-05-21 13:22:50 +09:00
parent f4b01ed19e
commit 86ef7a912d
+1 -1
View File
@@ -309,7 +309,7 @@ mrb_rational_new(mrb_state *mrb, mrb_int nume, mrb_int deno)
static mrb_value
int_lshift(mrb_state *mrb, mrb_value v, mrb_int n)
{
if (mrb_integer_p(v)) {
if (mrb_integer_p(v) && n < (mrb_int)sizeof(long) * CHAR_BIT) {
mrb_float f = (mrb_float)mrb_integer(v);
f *= 1L<<n;
if (mrb_int_fit_p(f, mrb_float))