From 82e937f511eb61b1726ffdc57f71c2a067e31974 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 9 Jan 2007 15:11:01 +0000 Subject: * array.c (rb_ary_replace): use ptr and len of orig instead of shared. fixed: [ruby-dev:30116] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'array.c') diff --git a/array.c b/array.c index fae5fe016e..7f9925292a 100644 --- a/array.c +++ b/array.c @@ -2090,15 +2090,17 @@ rb_ary_replace(VALUE copy, VALUE orig) VALUE shared; VALUE *ptr; - rb_ary_modify(copy); - ary_iter_check(copy); orig = to_ary(orig); + rb_ary_modify_check(copy); + ary_iter_check(copy); if (copy == orig) return copy; shared = ary_make_shared(orig); - ptr = RARRAY(copy)->ptr; + if (!ARY_SHARED_P(copy)) { + ptr = RARRAY(copy)->ptr; xfree(ptr); - RARRAY(copy)->ptr = RARRAY(shared)->ptr; - RARRAY(copy)->len = RARRAY(shared)->len; + } + RARRAY(copy)->ptr = RARRAY(orig)->ptr; + RARRAY(copy)->len = RARRAY(orig)->len; RARRAY(copy)->aux.shared = shared; FL_SET(copy, ELTS_SHARED); -- cgit v1.2.3