summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-01 04:50:38 +0000
committerngoto <ngoto@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-07-01 04:50:38 +0000
commit10e28726a149d7d01e0c3dedb9694ec312cd8a9d (patch)
tree1a3f48eb9d077bbc8b2c80b772988d4444cade24
parent6734a0c3d9cf46d3c7e2b0368fd42ab40e74a5c8 (diff)
* 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
-rw-r--r--ChangeLog7
-rw-r--r--string.c4
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 2428418175..c695bd9805 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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().
diff --git a/string.c b/string.c
index 50130a1754..81f71afb4d 100644
--- a/string.c
+++ b/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);