зеркало из https://github.com/github/ruby.git
string.c: enable capacity when setting capa
* 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/trunk@44803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5b92c0bea3
Коммит
bebc52a4a7
|
@ -1,3 +1,9 @@
|
|||
Tue Feb 4 12:55:31 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.
|
||||
|
||||
Tue Feb 4 12:45:15 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* dir.c (glob_make_pattern): all alphabets are magic characters on
|
||||
|
|
1
string.c
1
string.c
|
@ -1503,6 +1503,7 @@ rb_str_modify_expand(VALUE str, long expand)
|
|||
int termlen = TERM_LEN(str);
|
||||
if (!STR_EMBED_P(str)) {
|
||||
REALLOC_N(RSTRING(str)->as.heap.ptr, char, capa + termlen);
|
||||
STR_UNSET_NOCAPA(str);
|
||||
RSTRING(str)->as.heap.aux.capa = capa;
|
||||
}
|
||||
else if (capa + termlen > RSTRING_EMBED_LEN_MAX + 1) {
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче