From 92f510a9d9014afdaa2f26a04ff250455ea35162 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 13 Mar 2008 16:39:45 +0000 Subject: * array.c (rb_ary_slice_bang): should not use rb_ary_subseq() which shares internal pointer. splice modifies the receiver right after subseq. [ruby-dev:34005] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'array.c') diff --git a/array.c b/array.c index 41a94783fb..6fa4081159 100644 --- a/array.c +++ b/array.c @@ -1790,7 +1790,8 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary) pos = RARRAY_LEN(ary) + pos; if (pos < 0) return Qnil; } - arg2 = rb_ary_subseq(ary, pos, len); + arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos); + RBASIC(arg2)->klass = rb_obj_class(ary); rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */ return arg2; } -- cgit v1.2.3