From 8455344bf3fd92ca00f598accfe6b3eb29ddcb0c Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 6 Nov 2020 12:52:18 +0900 Subject: Skip too big left shift in `flo_shift()`. --- src/numeric.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/numeric.c b/src/numeric.c index 988342e88..fcabc6d60 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -611,6 +611,10 @@ flo_shift(mrb_state *mrb, mrb_value x, mrb_int width) return x; } val = mrb_float(x); + if (width < -MRB_INT_BIT/2) { + if (val < 0) return mrb_fixnum_value(-1); + return mrb_fixnum_value(0); + } if (width < 0) { while (width++) { val /= 2; -- cgit v1.2.3