mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
array.c: check for negative shift size.
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user