diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-17 14:38:15 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-11-17 16:20:53 +0900 |
| commit | a8cd364ece004097430d8d8567e06f2283106444 (patch) | |
| tree | 044a22fbed91f71efb944463614a70210143ee62 /src/numeric.c | |
| parent | 9fbf0ef886b5601c0c6cc8a24145a805283c9982 (diff) | |
| download | mruby-a8cd364ece004097430d8d8567e06f2283106444.tar.gz mruby-a8cd364ece004097430d8d8567e06f2283106444.zip | |
Detect overflow in `flo_shift()`.
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/numeric.c b/src/numeric.c index dc763b7ff..fec79ffd1 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -610,7 +610,9 @@ flo_shift(mrb_state *mrb, mrb_value x, mrb_int width) val *= 2; } } - return mrb_int_value(mrb, (mrb_int)val); + if (FIXABLE_FLOAT(val)) + return mrb_int_value(mrb, (mrb_int)val); + return mrb_float_value(mrb, val); } static mrb_value |
