diff --git a/ChangeLog b/ChangeLog index b80165670d..5cdfe6ceda 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Jul 1 11:41:12 2011 NARUSE, Yui + + * string.c (tr_trans): free heap ptr when the str is not embeded. + patched by Eric Wong. [Bug #4956] [ruby-core:37708] + Fri Jul 1 11:07:43 2011 KOSAKI Motohiro * thread.c (do_select): fix memory leak. 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;