summaryrefslogtreecommitdiffhomepage
path: root/src/numeric.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-11-06 12:52:18 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-11-06 12:52:18 +0900
commit8455344bf3fd92ca00f598accfe6b3eb29ddcb0c (patch)
treee32393b64d3144c0527021759450fa119e0b24ce /src/numeric.c
parent2a52ebcc5627cac73cfe162a48a3964d285f321b (diff)
downloadmruby-8455344bf3fd92ca00f598accfe6b3eb29ddcb0c.tar.gz
mruby-8455344bf3fd92ca00f598accfe6b3eb29ddcb0c.zip
Skip too big left shift in `flo_shift()`.
Diffstat (limited to 'src/numeric.c')
-rw-r--r--src/numeric.c4
1 files changed, 4 insertions, 0 deletions
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;