* string.c (rb_str_resize): should consider the capacity instead
  of the old length, as pointed out by nagachika.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46413 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-06-12 11:33:12 +00:00
Родитель 595782b924
Коммит 85bbacbba2
2 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Thu Jun 12 20:32:28 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_resize): should consider the capacity instead
of the old length, as pointed out by nagachika.
Thu Jun 12 18:31:01 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com> Thu Jun 12 18:31:01 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* lib/net/http/responses.rb: added Net::HTTPPermanentRedirect(308) * lib/net/http/responses.rb: added Net::HTTPPermanentRedirect(308)

Просмотреть файл

@ -1996,7 +1996,7 @@ rb_str_resize(VALUE str, long len)
if (len == slen) return str; if (len == slen) return str;
str_make_independent_expand(str, len - slen); str_make_independent_expand(str, len - slen);
} }
else if (slen < len || slen - len > 1024) { else if (slen < len || (RSTRING(str)->as.heap.aux.capa - len) > (len < 1024 ? len : 1024)) {
REALLOC_N(RSTRING(str)->as.heap.ptr, char, len + termlen); REALLOC_N(RSTRING(str)->as.heap.ptr, char, len + termlen);
} }
else if (len == slen) return str; else if (len == slen) return str;