From 88a9b878162b484099d3ff9c3c9579b98a7f1f8e Mon Sep 17 00:00:00 2001 From: naruse Date: Sun, 30 Jan 2011 20:42:40 +0000 Subject: * array.c (rb_ary_uniq_bang): call ARY_SET_LEN(ary, 0) before rb_resize_capa because rb_resize_capa expects resized length is smaller than current array length. call rb_ary_unshare before rb_resize_capa because rb_resize_capa losts the reference to original shared array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- array.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'array.c') diff --git a/array.c b/array.c index 6420e5b645..e776ebdc6a 100644 --- a/array.c +++ b/array.c @@ -3484,8 +3484,11 @@ rb_ary_uniq_bang(VALUE ary) if (RARRAY_LEN(ary) == (i = RHASH_SIZE(hash))) { return Qnil; } - ary_resize_capa(ary, i); ARY_SET_LEN(ary, 0); + if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { + rb_ary_unshare(ary); + } + ary_resize_capa(ary, i); st_foreach(RHASH_TBL(hash), push_value, ary); } else { -- cgit v1.2.3