summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/string.c b/string.c
index 9a85f81493..711918b4e6 100644
--- a/string.c
+++ b/string.c
@@ -5117,6 +5117,9 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
CHECK_IF_ASCII(c);
t += tlen;
}
+ if (!STR_EMBED_P(str)) {
+ xfree(RSTRING(str)->as.heap.ptr);
+ }
*t = '\0';
RSTRING(str)->as.heap.ptr = buf;
RSTRING(str)->as.heap.len = t - buf;