summaryrefslogtreecommitdiff
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 49e3c181527..2fb67efe923 100644
--- a/string.c
+++ b/string.c
@@ -4158,7 +4158,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
memcpy(p + beg0, rp, rlen);
len += rlen - plen;
STR_SET_LEN(str, len);
- RSTRING_PTR(str)[len] = '\0';
+ TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str));
ENC_CODERANGE_SET(str, cr);
if (tainted) OBJ_TAINT(str);