diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-19 17:32:31 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-19 17:32:31 +0000 |
commit | 20210d22c6e9f0f5b28ff1b5881edebaf038cd63 (patch) | |
tree | c9889a6dc2f47939c8f552144abe9feee9765811 /transcode.c | |
parent | c45c1ec209cd07eef351f20dc18a184834677a73 (diff) | |
download | ruby-20210d22c6e9f0f5b28ff1b5881edebaf038cd63.tar.gz ruby-20210d22c6e9f0f5b28ff1b5881edebaf038cd63.tar.xz ruby-20210d22c6e9f0f5b28ff1b5881edebaf038cd63.zip |
* transcode.c (rb_econv_open): fix memory leak.
(rb_econv_close): ditto.
fixed by shinichiro.h. [ruby-dev:35880]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'transcode.c')
-rw-r--r-- | transcode.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/transcode.c b/transcode.c index 6ef4e8404..44fd7e51c 100644 --- a/transcode.c +++ b/transcode.c @@ -743,14 +743,18 @@ rb_econv_open(const char *from, const char *to, int flags) 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 @@ rb_econv_open(const char *from, const char *to, int flags) 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 @@ rb_econv_close(rb_econv_t *ec) if (ec->elems[i].out_buf_start) xfree(ec->elems[i].out_buf_start); } - + xfree(ec->in_buf_start); xfree(ec->elems); xfree(ec); } |