summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-16 15:54:46 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-16 15:54:46 +0000
commit46561d573e92bcb0de52d825b7731aaac3865c17 (patch)
tree3d88c796769bedc1db3ec5a6ea85f534aecb0ec8
parentd423965b61004063dd3c9666fdbef5f85d122de4 (diff)
merge revision(s) r44803: [Backport #9484]
* string.c (rb_str_modify_expand): enable capacity and disable assocation with packed objects when setting capa, so that pack("p") string fails to unpack properly after modified. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--string.c1
-rw-r--r--test/ruby/test_pack.rb1
-rw-r--r--version.h6
4 files changed, 11 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f4cb2f2e7..1f2f464f03 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Feb 17 00:45:44 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_modify_expand): enable capacity and disable
+ association with packed objects when setting capa, so that
+ pack("p") string fails to unpack properly after modified.
+
Sun Feb 16 01:36:57 2014 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/yaml/emitter.c: merge libyaml 0.1.5
diff --git a/string.c b/string.c
index 6ba920a718..3c61c6a459 100644
--- a/string.c
+++ b/string.c
@@ -1387,6 +1387,7 @@ rb_str_modify_expand(VALUE str, long expand)
long capa = len + expand;
if (!STR_EMBED_P(str)) {
REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa+1);
+ STR_UNSET_NOCAPA(str);
RSTRING(str)->as.heap.aux.capa = capa;
}
else if (capa > RSTRING_EMBED_LEN_MAX) {
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index 76956ef25f..b3dde2058f 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -181,6 +181,7 @@ class TestPack < Test::Unit::TestCase
assert_equal a[0], a.pack("p").unpack("p")[0]
assert_equal a, a.pack("p").freeze.unpack("p*")
assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") }
+ assert_raise(ArgumentError) { (a.pack("p") << "d").unpack("p*") }
end
def test_format_string_modified
diff --git a/version.h b/version.h
index 7281ca7502..705a4cd3ad 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-02-16"
-#define RUBY_PATCHLEVEL 423
+#define RUBY_RELEASE_DATE "2014-02-17"
+#define RUBY_PATCHLEVEL 424
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 16
+#define RUBY_RELEASE_DAY 17
#include "ruby/version.h"