From f8c8a38d30f6e23211f7ab1ca11b84d1ab85972f Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 18 Dec 2002 11:50:49 +0000 Subject: [PATCH] * string.c (rb_str_dup_frozen): handle tail shared string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 +++- string.c | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a3ef0141d..794314b996 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,10 @@ -Wed Dec 18 02:27:34 2002 Nobuyoshi Nakada +Wed Dec 18 03:52:55 2002 Nobuyoshi Nakada * string.c (rb_str_new4): handle tail shared string. (ruby-bugs-ja:PR#370) + * string.c (rb_str_dup_frozen): ditto. + Tue Dec 17 21:08:29 2002 Nobuyoshi Nakada * node.h (NODE_ATTRASGN): new node, assignment to attribute. diff --git a/string.c b/string.c index 01316b9c23..26d1cbf2af 100644 --- a/string.c +++ b/string.c @@ -517,8 +517,11 @@ rb_str_dup_frozen(str) VALUE str; { if (FL_TEST(str, ELTS_SHARED)) { - OBJ_FREEZE(RSTRING(str)->aux.shared); - return RSTRING(str)->aux.shared; + VALUE shared = RSTRING(str)->aux.shared; + if (RSTRING(shared)->len == RSTRING(str)->len) { + OBJ_FREEZE(shared); + return shared; + } } if (OBJ_FROZEN(str)) return str; str = rb_str_dup(str);