summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-01 05:28:48 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-01 05:28:48 +0000
commitf4dda52025433e232f931ffa1cb0473684128a5a (patch)
tree7746234330c6617c8e4a6cb7c3b89e98f52d2495 /string.c
parentc05fd75befe5b6021e7926452d6813c3472f540f (diff)
* string.c (tr_trans): free heap ptr when the str is not embeded.
patched by Eric Wong. [Bug #4956] [ruby-core:37708] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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;