aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/string.c b/string.c
index 8cfbb56bdf..1b06370bb7 100644
--- a/string.c
+++ b/string.c
@@ -513,7 +513,7 @@ rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags,
switch (ret) {
case econv_destination_buffer_full:
/* destination buffer short */
- len *= 2;
+ len = len < 2 ? 2 : len * 2;
rb_str_resize(newstr, len);
goto retry;