ruby-changes:27804
From: nobu <ko1@a...>
Date: Thu, 21 Mar 2013 14:14:08 +0900 (JST)
Subject: [ruby-changes:27804] nobu:r39856 (trunk): string.c: potential memory leak
nobu 2013-03-21 14:13:59 +0900 (Thu, 21 Mar 2013) New Revision: 39856 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39856 Log: string.c: potential memory leak * string.c (rb_str_conv_enc_opts): allocate and hide wrapper before creating converter to be wrapped, to get rid of potential memory leak by failure on the allocation. Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 39855) +++ string.c (revision 39856) @@ -518,9 +518,10 @@ rb_str_conv_enc_opts(VALUE str, rb_encod https://github.com/ruby/ruby/blob/trunk/string.c#L518 newstr = rb_str_new(0, len); olen = len; + econv_wrapper = rb_obj_alloc(rb_cEncodingConverter); + RBASIC(econv_wrapper)->klass = 0; ec = rb_econv_open_opts(from->name, to->name, ecflags, ecopts); if (!ec) return str; - econv_wrapper = rb_obj_alloc(rb_cEncodingConverter); DATA_PTR(econv_wrapper) = ec; sp = (unsigned char*)RSTRING_PTR(str); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/