summaryrefslogtreecommitdiffhomepage
path: root/src/array.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-05-27 08:13:49 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2021-05-27 08:13:49 +0900
commit9a72869043e0377ec549a325a074e592f82ef5ed (patch)
tree98d9a629e8116fd215faa74c605da1dbf37b17d3 /src/array.c
parentc019d8d34d2db5de218802d923e6d0197a2ffca0 (diff)
downloadmruby-9a72869043e0377ec549a325a074e592f82ef5ed.tar.gz
mruby-9a72869043e0377ec549a325a074e592f82ef5ed.zip
array.c: check for negative shift size.
Diffstat (limited to 'src/array.c')
-rw-r--r--src/array.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/array.c b/src/array.c
index 739b2b3e1..a49c2399c 100644
--- a/src/array.c
+++ b/src/array.c
@@ -591,6 +591,7 @@ mrb_ary_shift_m(mrb_state *mrb, mrb_value self)
};
ary_modify_check(mrb, a);
if (len == 0 || n == 0) return mrb_ary_new(mrb);
+ if (n < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array shift");
if (n > len) n = len;
val = mrb_ary_new_from_values(mrb, n, ARY_PTR(a));
if (ARY_SHARED_P(a)) {