mrb_str_cat: capa should not be zero to avoid infinite loops.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-08-18 23:41:31 +09:00
parent a06adb176f
commit a8bd06904d
+1
View File
@@ -2566,6 +2566,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
mrb_raise(mrb, E_ARGUMENT_ERROR, "string size too big");
}
if (capa <= total) {
if (capa == 0) capa = 1;
while (capa <= total) {
if (capa <= MRB_INT_MAX / 2) {
capa *= 2;