From 715633ba6e982dc5404abeafc5246c31af92ac10 Mon Sep 17 00:00:00 2001 From: nagachika Date: Mon, 15 Jul 2024 10:41:21 +0900 Subject: follow-up for a54c717c7a74b91a3cdf20742c355e3ea42052d1. --- string.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'string.c') 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); -- cgit v1.2.3