summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-18 23:40:27 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-18 23:42:33 +0900
commita06adb176f3c0d44b15ff41fa7788ae408147df2 (patch)
tree50d8e5c29ca62743aff56a207d305fc7b9064d41 /src/string.c
parent8b5be554c7b7b45722be9baccfd1278905a2565e (diff)
downloadmruby-a06adb176f3c0d44b15ff41fa7788ae408147df2.tar.gz
mruby-a06adb176f3c0d44b15ff41fa7788ae408147df2.zip
`mrb_str_cat`: `capa` should be bigger than `total`.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string.c b/src/string.c
index c5efd779f..e382b470c 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2566,15 +2566,15 @@ 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) {
- while (total > capa) {
+ while (capa <= total) {
if (capa <= MRB_INT_MAX / 2) {
capa *= 2;
}
else {
- capa = total;
+ capa = total+1;
}
}
- if (capa < total || capa > MRB_INT_MAX) {
+ if (capa <= total || capa > MRB_INT_MAX) {
goto size_error;
}
resize_capa(mrb, s, capa);