Unverified Commit c626b823 authored by ksss's avatar ksss

Check overflow string length

Fix #3360
parent 987daa64
...@@ -756,6 +756,9 @@ mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other) ...@@ -756,6 +756,9 @@ mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
s2 = mrb_str_ptr(other); s2 = mrb_str_ptr(other);
len = RSTR_LEN(s1) + RSTR_LEN(s2); len = RSTR_LEN(s1) + RSTR_LEN(s2);
if (len < 0 || len >= MRB_INT_MAX) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
if (RSTRING_CAPA(self) < len) { if (RSTRING_CAPA(self) < len) {
resize_capa(mrb, s1, len); resize_capa(mrb, s1, len);
} }
......
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