summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2024-07-15 10:41:21 +0900
committernagachika <nagachika@ruby-lang.org>2024-07-15 10:41:21 +0900
commit715633ba6e982dc5404abeafc5246c31af92ac10 (patch)
treecfd2efe9f7ae841c272ac300a1f3dd84aa4747c7
parent90f4c5dc73af3fff76500dd4223792a6d9f58636 (diff)
follow-up for a54c717c7a74b91a3cdf20742c355e3ea42052d1.
-rw-r--r--string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/string.c b/string.c
index 5af25b875e..97c570de31 100644
--- a/string.c
+++ b/string.c
@@ -1938,7 +1938,11 @@ rb_str_init(int argc, VALUE *argv, VALUE str)
/* make noembed always */
const size_t size = (size_t)capa + termlen;
const char *const old_ptr = RSTRING_PTR(str);
+#if USE_RVARGC
const size_t osize = RSTRING_LEN(str) + TERM_LEN(str);
+#else
+ const size_t osize = RSTRING_EMBED_LEN_MAX + 1;
+#endif
char *new_ptr = ALLOC_N(char, size);
if (STR_EMBED_P(str)) RUBY_ASSERT((long)osize <= str_embed_capa(str));
memcpy(new_ptr, old_ptr, osize < size ? osize : size);