From 342b1de65c5f044e1f3dc08b6e04c9cd0206abc3 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 31 Dec 2016 23:31:45 +0900 Subject: str_buf_cat(): should allocate at least RSTRING_EMBED_LEN_MAX+1. --- src/string.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/string.c b/src/string.c index 56eeef3a2..d41237f44 100644 --- a/src/string.c +++ b/src/string.c @@ -158,6 +158,8 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len) capa = RSTRING_EMBED_LEN_MAX; else capa = s->as.heap.aux.capa; + if (capa <= RSTRING_EMBED_LEN_MAX) + capa = RSTRING_EMBED_LEN_MAX+1; total = RSTR_LEN(s)+len; if (total >= MRB_INT_MAX) { -- cgit v1.2.3