summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2017-08-18 23:41:31 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2017-08-18 23:42:34 +0900
commita8bd06904decf2a4641c068fcb271b5b13d37914 (patch)
tree29d8d0dcc0037a680d3826c7d350a5354466f5f6 /src/string.c
parenta06adb176f3c0d44b15ff41fa7788ae408147df2 (diff)
downloadmruby-a8bd06904decf2a4641c068fcb271b5b13d37914.tar.gz
mruby-a8bd06904decf2a4641c068fcb271b5b13d37914.zip
`mrb_str_cat`: `capa` should not be zero to avoid infinite loops.
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index e382b470c..c2526f354 100644
--- a/src/string.c
+++ b/src/string.c
@@ -2566,6 +2566,7 @@ 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) {
+ if (capa == 0) capa = 1;
while (capa <= total) {
if (capa <= MRB_INT_MAX / 2) {
capa *= 2;