Skip to content

Commit

Permalink
str_buf_cat(): should allocate at least RSTRING_EMBED_LEN_MAX+1.
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 31, 2016
1 parent cfdd1e3 commit 342b1de
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 342b1de

Please sign in to comment.