ruby-changes:39347
From: nobu <ko1@a...>
Date: Wed, 29 Jul 2015 16:00:56 +0900 (JST)
Subject: [ruby-changes:39347] nobu:r51428 (trunk): string.c: empty non-embed case
nobu 2015-07-29 16:00:25 +0900 (Wed, 29 Jul 2015) New Revision: 51428 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51428 Log: string.c: empty non-embed case * string.c (str_buf_cat): consider empty non-embed string case, not to loop infinitely. [ruby-core:70074] [Bug #11383] Modified files: trunk/ChangeLog trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51427) +++ ChangeLog (revision 51428) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Jul 29 16:00:22 2015 Nobuyoshi Nakada <nobu@r...> + + * string.c (str_buf_cat): consider empty non-embed string case, + not to loop infinitely. [ruby-core:70074] [Bug #11383] + Wed Jul 29 15:25:19 2015 Nobuyoshi Nakada <nobu@r...> * vm_eval.c (send_internal): set method_missing_reason before Index: string.c =================================================================== --- string.c (revision 51427) +++ string.c (revision 51428) @@ -2292,12 +2292,17 @@ str_buf_cat(VALUE str, const char *ptr, https://github.com/ruby/ruby/blob/trunk/string.c#L2292 } total = olen + len; if (capa <= total) { - while (total > capa) { - if (capa > LONG_MAX / 2) { - capa = (total + 4095) / 4096 * 4096; - break; + if (LIKELY(capa > 0)) { + while (total > capa) { + if (capa > LONG_MAX / 2) { + capa = (total + 4095) / 4096 * 4096; + break; + } + capa = 2 * capa; } - capa = 2 * capa; + } + else { + capa = total; } RESIZE_CAPA_TERM(str, capa, termlen); sptr = RSTRING_PTR(str); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/