mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Add negative check in mrb_str_resize; fix #4062
This commit is contained in:
@@ -708,6 +708,9 @@ mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len)
|
||||
mrb_int slen;
|
||||
struct RString *s = mrb_str_ptr(str);
|
||||
|
||||
if (len < 0) {
|
||||
mrb_raisef(mrb, E_ARGUMENT_ERROR, "negative (or overflowed) string size");
|
||||
}
|
||||
mrb_str_modify(mrb, s);
|
||||
slen = RSTR_LEN(s);
|
||||
if (len != slen) {
|
||||
|
||||
Reference in New Issue
Block a user