зеркало из https://github.com/github/ruby.git
* string.c (rb_str_subseq, str_substr): When RSTRING_EMBED_LEN_MAX
is used, TERM_LEN(str) should be considered with it because embedded strings are also processed by TERM_FILL. Additional fix for [Bug #12536] [ruby-dev:49699]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6734a0c3d9
Коммит
10e28726a1
|
@ -1,3 +1,10 @@
|
|||
Fri Jul 1 13:26:39 2016 Naohisa Goto <ngotogenome@gmail.com>
|
||||
|
||||
* string.c (rb_str_subseq, str_substr): When RSTRING_EMBED_LEN_MAX
|
||||
is used, TERM_LEN(str) should be considered with it because
|
||||
embedded strings are also processed by TERM_FILL.
|
||||
Additional fix for [Bug #12536] [ruby-dev:49699].
|
||||
|
||||
Fri Jul 1 12:11:01 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* .gdbinit (rb_count_objects): added gdb version of count_objects().
|
||||
|
|
4
string.c
4
string.c
|
@ -2226,7 +2226,7 @@ rb_str_subseq(VALUE str, long beg, long len)
|
|||
{
|
||||
VALUE str2;
|
||||
|
||||
if (RSTRING_EMBED_LEN_MAX < len && SHARABLE_SUBSTRING_P(beg, len, RSTRING_LEN(str))) {
|
||||
if ((RSTRING_EMBED_LEN_MAX + 1 - TERM_LEN(str)) < len && SHARABLE_SUBSTRING_P(beg, len, RSTRING_LEN(str))) {
|
||||
long olen;
|
||||
str2 = rb_str_new_shared(rb_str_new_frozen(str));
|
||||
RSTRING(str2)->as.heap.ptr += beg;
|
||||
|
@ -2344,7 +2344,7 @@ str_substr(VALUE str, long beg, long len, int empty)
|
|||
char *p = rb_str_subpos(str, beg, &len);
|
||||
|
||||
if (!p) return Qnil;
|
||||
if (len > RSTRING_EMBED_LEN_MAX && SHARABLE_SUBSTRING_P(p, len, RSTRING_END(str))) {
|
||||
if (len > (RSTRING_EMBED_LEN_MAX + 1 - TERM_LEN(str)) && SHARABLE_SUBSTRING_P(p, len, RSTRING_END(str))) {
|
||||
long ofs = p - RSTRING_PTR(str);
|
||||
str2 = rb_str_new_frozen(str);
|
||||
str2 = str_new_shared(rb_obj_class(str2), str2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче