Skip to content

Commit

Permalink
Improve capacity enhancing conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Jan 6, 2017
1 parent c6a1172 commit 885d929
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@ ary_expand_capa(mrb_state *mrb, struct RArray *a, size_t len)
capa *= 2;
}
else {
goto size_error;
capa = len;
}
}
if (capa < len || capa > MRB_INT_MAX) {
if (capa < len || capa > ARY_MAX_SIZE) {
goto size_error;
}

Expand Down
2 changes: 1 addition & 1 deletion src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len)
capa *= 2;
}
else {
goto size_error;
capa = total;
}
}
if (capa < total || capa > MRB_INT_MAX) {
Expand Down

0 comments on commit 885d929

Please sign in to comment.