mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
array.c: check integer overflow in mrb_ary_set().
This commit is contained in:
@@ -716,6 +716,9 @@ mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
|
||||
mrb_raisef(mrb, E_INDEX_ERROR, "index %i out of array", n - len);
|
||||
}
|
||||
}
|
||||
if (n == MRB_INT_MAX) {
|
||||
mrb_raise(mrb, E_INDEX_ERROR, "index too big");
|
||||
}
|
||||
if (len <= n) {
|
||||
if (ARY_CAPA(a) <= n)
|
||||
ary_expand_capa(mrb, a, n + 1);
|
||||
|
||||
Reference in New Issue
Block a user