summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/numeric.c3
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;