ruby-changes:7192
From: akr <ko1@a...>
Date: Wed, 20 Aug 2008 02:32:50 +0900 (JST)
Subject: [ruby-changes:7192] Ruby:r18710 (trunk): * transcode.c (rb_econv_open): fix memory leak.
akr 2008-08-20 02:32:31 +0900 (Wed, 20 Aug 2008) New Revision: 18710 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18710 Log: * transcode.c (rb_econv_open): fix memory leak. (rb_econv_close): ditto. fixed by shinichiro.h. [ruby-dev:35880] Modified files: trunk/ChangeLog trunk/transcode.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18709) +++ ChangeLog (revision 18710) @@ -1,3 +1,9 @@ +Wed Aug 20 02:27:42 2008 Tanaka Akira <akr@f...> + + * transcode.c (rb_econv_open): fix memory leak. + (rb_econv_close): ditto. + fixed by shinichiro.h. [ruby-dev:35880] + Tue Aug 19 21:50:43 2008 Tanaka Akira <akr@f...> * include/ruby/io.h (rb_fopen): declaration removed. Index: transcode.c =================================================================== --- transcode.c (revision 18709) +++ transcode.c (revision 18710) @@ -743,14 +743,18 @@ num_trans = transcode_search_path(from, to, trans_open_i, (void *)&entries); - if (num_trans < 0 || !entries) + if (num_trans < 0 || !entries) { + xfree(entries); return NULL; + } if (flags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER)) { const char *name = (flags & ECONV_CRLF_NEWLINE_ENCODER) ? "crlf_newline" : "cr_newline"; transcoder_entry_t *e = get_transcoder_entry("", name); - if (!e) + if (!e) { + xfree(entries); return NULL; + } MEMMOVE(entries+1, entries, transcoder_entry_t *, num_trans); entries[0] = e; num_trans++; @@ -758,12 +762,15 @@ if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) { transcoder_entry_t *e = get_transcoder_entry("universal_newline", ""); - if (!e) + if (!e) { + xfree(entries); return NULL; + } entries[num_trans++] = e; } ec = rb_econv_open_by_transcoder_entries(num_trans, entries); + xfree(entries); if (!ec) rb_raise(rb_eArgError, "encoding conversion not supported (from %s to %s)", from, to); @@ -1200,7 +1207,7 @@ if (ec->elems[i].out_buf_start) xfree(ec->elems[i].out_buf_start); } - + xfree(ec->in_buf_start); xfree(ec->elems); xfree(ec); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/