summaryrefslogtreecommitdiff
path: root/strftime.c
diff options
context:
space:
mode:
Diffstat (limited to 'strftime.c')
-rw-r--r--strftime.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/strftime.c b/strftime.c
index 33e7d3fdb8..906e8360a9 100644
--- a/strftime.c
+++ b/strftime.c
@@ -171,7 +171,9 @@ resize_buffer(VALUE ftime, char *s, const char **start, const char **endp,
ptrdiff_t n, size_t maxsize)
{
size_t len = s - *start;
- size_t nlen = len + n * 2;
+ size_t need = len + n * 2;
+ size_t nlen = rb_str_capacity(ftime);
+ while (nlen < need) nlen <<= 1;
if (nlen < len || nlen > maxsize) {
return 0;