Skip to content

Commit

Permalink
* string.c (tr_trans): free heap ptr when the str is not embeded.
Browse files Browse the repository at this point in the history
  patched by Eric Wong. [Bug ruby#4956] [ruby-core:37708]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nurse committed Jul 1, 2011
1 parent c05fd75 commit f4dda52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
@@ -1,3 +1,8 @@
Fri Jul 1 11:41:12 2011 NARUSE, Yui <naruse@ruby-lang.org>

* 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 <kosaki.motohiro@gmail.com> Fri Jul 1 11:07:43 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>


* thread.c (do_select): fix memory leak. * thread.c (do_select): fix memory leak.
Expand Down
3 changes: 3 additions & 0 deletions string.c
Expand Up @@ -5117,6 +5117,9 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
CHECK_IF_ASCII(c); CHECK_IF_ASCII(c);
t += tlen; t += tlen;
} }
if (!STR_EMBED_P(str)) {
xfree(RSTRING(str)->as.heap.ptr);
}
*t = '\0'; *t = '\0';
RSTRING(str)->as.heap.ptr = buf; RSTRING(str)->as.heap.ptr = buf;
RSTRING(str)->as.heap.len = t - buf; RSTRING(str)->as.heap.len = t - buf;
Expand Down

0 comments on commit f4dda52

Please sign in to comment.