string.c: check integer overflow in `mrb_str_aset()`.

parent 5777e33c
......@@ -1375,7 +1375,10 @@ mrb_str_aset(mrb_state *mrb, mrb_value str, mrb_value indx, mrb_value alen, mrb_
str_range_to_bytes(str, &beg, &len);
/* fall through */
case STR_BYTE_RANGE_CORRECTED:
str_replace_partial(mrb, str, beg, beg + len, replace);
if (mrb_int_add_overflow(beg, len, &len)) {
mrb_raise(mrb, E_RUNTIME_ERROR, "string index too big");
}
str_replace_partial(mrb, str, beg, len, replace);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment