summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-21 14:11:42 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-21 14:11:42 +0000
commit3cdf4f058e0f822c7ee685b700fe43f4837cb40a (patch)
treef16d4dc3e9480f2c709e059c87c367784aa03c04
parent539ab3056902c5946291433cb807ad7c5b8fea4c (diff)
merge revision(s) 58042: [Backport #13339]
string.c: use the usable size * string.c (rb_str_change_terminator_length): when called after the content has been copied, old terminator length no longer makes sense. use the whole usable size instead of capacity without terminator. [ruby-core:80257] [Bug #13339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@58046 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--string.c6
-rw-r--r--version.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/string.c b/string.c
index 83e27b6c15..f31d083c0c 100644
--- a/string.c
+++ b/string.c
@@ -2102,11 +2102,11 @@ str_fill_term(VALUE str, char *s, long len, int termlen)
void
rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen)
{
- long capa = str_capacity(str, oldtermlen);
+ long capa = str_capacity(str, oldtermlen) + oldtermlen;
long len = RSTRING_LEN(str);
assert(capa >= len);
- if (capa - len < termlen - oldtermlen) {
+ if (capa - len < termlen) {
rb_check_lockedtmp(str);
str_make_independent_expand(str, len, 0L, termlen);
}
@@ -2118,7 +2118,7 @@ rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int terml
if (!STR_EMBED_P(str)) {
/* modify capa instead of realloc */
assert(!FL_TEST((str), STR_SHARED));
- RSTRING(str)->as.heap.aux.capa = capa - (termlen - oldtermlen);
+ RSTRING(str)->as.heap.aux.capa = capa - termlen;
}
if (termlen > oldtermlen) {
TERM_FILL(RSTRING_PTR(str) + len, termlen);
diff --git a/version.h b/version.h
index 2abc2169f4..8daed58f86 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.4.0"
#define RUBY_RELEASE_DATE "2017-03-21"
-#define RUBY_PATCHLEVEL 108
+#define RUBY_PATCHLEVEL 109
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3