Merge pull request #3364 from ksss/string2

Check overflow string length
This commit is contained in:
Yukihiro "Matz" Matsumoto
2016-12-25 01:35:44 +09:00
committed by GitHub
+3
View File
@@ -759,6 +759,9 @@ mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
}
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) {
resize_capa(mrb, s1, len);
}