summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2016-12-31 23:31:45 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2016-12-31 23:31:45 +0900
commit342b1de65c5f044e1f3dc08b6e04c9cd0206abc3 (patch)
tree54e5219e4d1a6ac56d81e0ee71d8346e10f747c5 /src
parentcfdd1e3cc6ec9ac7ba81ec6fad5d5ba4d11334b9 (diff)
downloadmruby-342b1de65c5f044e1f3dc08b6e04c9cd0206abc3.tar.gz
mruby-342b1de65c5f044e1f3dc08b6e04c9cd0206abc3.zip
str_buf_cat(): should allocate at least RSTRING_EMBED_LEN_MAX+1.
Diffstat (limited to 'src')
-rw-r--r--src/string.c2
1 files changed, 2 insertions, 0 deletions
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) {