Skip to content

Commit 3e5f9b1

Browse files
committed
merge revision(s) 44803: [Backport ruby#9478]
* 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://svn.ruby-lang.org/ruby/branches/ruby_2_1@44819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 7933cae commit 3e5f9b1

4 files changed

Lines changed: 11 additions & 3 deletions

File tree

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Wed Feb 5 11:13:21 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
2+
3+
* string.c (rb_str_modify_expand): enable capacity and disable
4+
assocation with packed objects when setting capa, so that
5+
pack("p") string fails to unpack properly after modified.
6+
17
Sun Feb 2 22:39:28 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
28

39
* lib/delegate.rb (Delegator): keep source information methods

string.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,7 @@ rb_str_modify_expand(VALUE str, long expand)
14651465
int termlen = TERM_LEN(str);
14661466
if (!STR_EMBED_P(str)) {
14671467
REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen);
1468+
STR_UNSET_NOCAPA(str);
14681469
RSTRING(str)->as.heap.aux.capa = capa;
14691470
}
14701471
else if (capa + termlen > RSTRING_EMBED_LEN_MAX + 1) {

test/ruby/test_pack.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ def test_pack_p
181181
assert_equal a[0], a.pack("p").unpack("p")[0]
182182
assert_equal a, a.pack("p").freeze.unpack("p*")
183183
assert_raise(ArgumentError) { (a.pack("p") + "").unpack("p*") }
184+
assert_raise(ArgumentError) { (a.pack("p") << "d").unpack("p*") }
184185
end
185186

186187
def test_format_string_modified

version.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#define RUBY_VERSION "2.1.1"
2-
#define RUBY_RELEASE_DATE "2014-02-02"
3-
#define RUBY_PATCHLEVEL 15
2+
#define RUBY_RELEASE_DATE "2014-02-05"
3+
#define RUBY_PATCHLEVEL 16
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 2
7-
#define RUBY_RELEASE_DAY 2
7+
#define RUBY_RELEASE_DAY 5
88

99
#include "ruby/version.h"
1010

0 commit comments

Comments
 (0)