diff options
| author | murase_syuka <[email protected]> | 2015-11-18 00:15:47 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2015-11-18 01:00:46 +0900 |
| commit | a4d5588101979a49f842c8a2f1ea710adb788d0d (patch) | |
| tree | 2d015cb7b1fbf908036a4f4561311d44382a4ec3 /src/numeric.c | |
| parent | 22464fe5a0a10f2b077eaba109ce1e912e4a77de (diff) | |
| download | mruby-a4d5588101979a49f842c8a2f1ea710adb788d0d.tar.gz mruby-a4d5588101979a49f842c8a2f1ea710adb788d0d.zip | |
Bugfix lshift() bit overflow; close #3023
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/numeric.c b/src/numeric.c index 6cceaeb9e..e64cd2d8d 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -821,7 +821,8 @@ static mrb_value lshift(mrb_state *mrb, mrb_int val, mrb_int width) { mrb_assert(width > 0); - if (width > NUMERIC_SHIFT_WIDTH_MAX) { + if ((width > NUMERIC_SHIFT_WIDTH_MAX) || + (val > (MRB_INT_MAX >> width))) { mrb_float f = (mrb_float)val; while (width--) { f *= 2; |
