diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-04-21 08:36:29 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-04-21 08:36:29 +0900 |
| commit | 3567b262227c6188da21bac2896eea4587bd1de5 (patch) | |
| tree | ae899b331e26ed243a2c280c245bdb41469f828e /src | |
| parent | d2cad9ac5b8db89fc9d21f5795846f983236798c (diff) | |
| download | mruby-3567b262227c6188da21bac2896eea4587bd1de5.tar.gz mruby-3567b262227c6188da21bac2896eea4587bd1de5.zip | |
Bit-shifting zero should be zero; ref #3620
Diffstat (limited to 'src')
| -rw-r--r-- | src/numeric.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/numeric.c b/src/numeric.c index 2117fcc3c..b4b85a9c6 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -995,6 +995,7 @@ fix_lshift(mrb_state *mrb, mrb_value x) return x; } val = mrb_fixnum(x); + if (val == 0) return x; if (width < 0) { return rshift(val, -width); } @@ -1019,6 +1020,7 @@ fix_rshift(mrb_state *mrb, mrb_value x) return x; } val = mrb_fixnum(x); + if (val == 0) return x; if (width < 0) { return lshift(mrb, val, -width); } |
