From a8bd06904decf2a4641c068fcb271b5b13d37914 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 18 Aug 2017 23:41:31 +0900 Subject: `mrb_str_cat`: `capa` should not be zero to avoid infinite loops. --- src/string.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/string.c b/src/string.c index e382b470c..c2526f354 100644 --- a/src/string.c +++ b/src/string.c @@ -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; -- cgit v1.2.3