From bebc52a4a721a1c1d5a98760d58df296ff0d2497 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 4 Feb 2014 03:55:32 +0000 Subject: 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 --- string.c | 1 + 1 file changed, 1 insertion(+) (limited to 'string.c') diff --git a/string.c b/string.c index ee57f92716..983c2a1166 100644 --- a/string.c +++ b/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) { -- cgit v1.2.3