Skip to content

Commit

Permalink
array.c: check integer overflow in mrb_ary_set().
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Mar 1, 2022
1 parent 9d8f3c6 commit 1508da4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/array.c
Expand Up @@ -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);
Expand Down

0 comments on commit 1508da4

Please sign in to comment.