aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/string.c b/string.c
index c8707c62a6..ffe2e6233a 100644
--- a/string.c
+++ b/string.c
@@ -1593,6 +1593,7 @@ str_make_independent_expand(VALUE str, long expand)
ptr = RSTRING(str)->as.heap.ptr;
STR_SET_EMBED(str);
memcpy(RSTRING(str)->as.ary, ptr, len);
+ RSTRING(str)->as.ary[len] = '\0'; /* Ensure string is terminated */
STR_SET_EMBED_LEN(str, len);
return;
}