summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-27 15:36:32 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-27 15:36:32 +0000
commitcd0a89b0931d51015e4e94b010926f0c75767cee (patch)
treefbbffee961abcea767a1ed70f60014f2ec174e99
parent909291085c87b41d6718c2630ee49210eb9d9684 (diff)
merge revision(s) r45534: [Backport #9709]
* string.c (str_buf_cat): should round up the capacity by 4KiB, but not number of rooms. [ruby-core:61886] [Bug #9709] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c2
-rw-r--r--test/ruby/test_string.rb11
-rw-r--r--version.h2
4 files changed, 18 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8389ca8a69..fb63027b55 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed May 28 00:29:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (str_buf_cat): should round up the capacity by 4KiB,
+ but not number of rooms. [ruby-core:61886] [Bug #9709]
+
Wed May 28 00:23:11 2014 NARUSE, Yui <naruse@ruby-lang.org>
* lib/xmlrpc/client.rb (do_rpc): don't check body length.
diff --git a/string.c b/string.c
index 983c2a1166..7f29cea2b6 100644
--- a/string.c
+++ b/string.c
@@ -2098,7 +2098,7 @@ str_buf_cat(VALUE str, const char *ptr, long len)
if (capa <= total) {
while (total > capa) {
if (capa + termlen >= LONG_MAX / 2) {
- capa = (total + 4095) / 4096;
+ capa = (total + 4095) / 4096 * 4096;
break;
}
capa = (capa + termlen) * 2;
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index 7ce1c0666c..57cea652b1 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -2219,6 +2219,17 @@ class TestString < Test::Unit::TestCase
assert_equal("foo", "" =~ //)
RUBY
end
+
+ def test_LSHIFT_neary_long_max
+ return unless @cls == String
+ assert_ruby_status([], <<-'end;', '[ruby-core:61886] [Bug #9709]')
+ begin
+ a = "a" * 0x4000_0000
+ a << "a" * 0x1_0000
+ rescue NoMemoryError
+ end
+ end;
+ end
end
class TestString2 < TestString
diff --git a/version.h b/version.h
index f6cf5e9385..062e5404e1 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-05-28"
-#define RUBY_PATCHLEVEL 108
+#define RUBY_PATCHLEVEL 109
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 5