* string.c (rb_str_shared_replace): remove corrupt noembed string

which causes SEGV.  [ruby-dev:35989]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18900 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-08-28 14:40:53 +00:00
parent fbfd237042
commit c543447ee0
2 changed files with 8 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Thu Aug 28 23:39:49 2008 Yusuke Endoh <mame@tsg.ne.jp>
* string.c (rb_str_shared_replace): remove corrupt noembed string
which causes SEGV. [ruby-dev:35989]
Thu Aug 28 23:36:15 2008 Tanaka Akira <akr@fsij.org>
* common.mk: dependency updated.

View File

@ -669,10 +669,9 @@ rb_str_shared_replace(VALUE str, VALUE str2)
else {
RSTRING(str)->as.heap.aux.capa = RSTRING(str2)->as.heap.aux.capa;
}
RSTRING(str2)->as.heap.ptr = 0; /* abandon str2 */
RSTRING(str2)->as.heap.len = 0;
RSTRING(str2)->as.heap.aux.capa = 0;
STR_UNSET_NOCAPA(str2);
STR_SET_EMBED(str2); /* abandon str2 */
RSTRING_PTR(str2)[0] = 0;
STR_SET_EMBED_LEN(str2, 0);
rb_enc_associate(str, enc);
ENC_CODERANGE_SET(str, cr);
}