mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 44803: [Backport #9485]
* 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_1_9_3@44830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
13848d6048
commit
b6a4e7cea0
4 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Feb 5 13:43:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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.
|
||||
|
||||
Sun Feb 2 05:48:42 2014 Eric Wong <e@80x24.org>
|
||||
|
||||
* io.c (rb_io_syswrite): add RB_GC_GUARD
|
||||
|
|
1
string.c
1
string.c
|
@ -1337,6 +1337,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) {
|
||||
|
|
|
@ -180,6 +180,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
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#define RUBY_VERSION "1.9.3"
|
||||
#define RUBY_PATCHLEVEL 513
|
||||
#define RUBY_PATCHLEVEL 514
|
||||
|
||||
#define RUBY_RELEASE_DATE "2014-02-05"
|
||||
#define RUBY_RELEASE_YEAR 2014
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue