Bit-shifting zero should be zero; ref #3620

parent d2cad9ac
...@@ -995,6 +995,7 @@ fix_lshift(mrb_state *mrb, mrb_value x) ...@@ -995,6 +995,7 @@ fix_lshift(mrb_state *mrb, mrb_value x)
return x; return x;
} }
val = mrb_fixnum(x); val = mrb_fixnum(x);
if (val == 0) return x;
if (width < 0) { if (width < 0) {
return rshift(val, -width); return rshift(val, -width);
} }
...@@ -1019,6 +1020,7 @@ fix_rshift(mrb_state *mrb, mrb_value x) ...@@ -1019,6 +1020,7 @@ fix_rshift(mrb_state *mrb, mrb_value x)
return x; return x;
} }
val = mrb_fixnum(x); val = mrb_fixnum(x);
if (val == 0) return x;
if (width < 0) { if (width < 0) {
return lshift(mrb, val, -width); return lshift(mrb, val, -width);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment