From c543447ee0283395aa7e28f8d66139ccfc3f6f10 Mon Sep 17 00:00:00 2001 From: mame Date: Thu, 28 Aug 2008 14:40:53 +0000 Subject: * 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 --- string.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'string.c') diff --git a/string.c b/string.c index 0451a7ccda..26b57b5e3b 100644 --- a/string.c +++ b/string.c @@ -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); } -- cgit v1.2.3