ruby-changes:18711
From: naruse <ko1@a...>
Date: Mon, 31 Jan 2011 05:50:54 +0900 (JST)
Subject: [ruby-changes:18711] Ruby:r30736 (trunk): * array.c (rb_ary_uniq_bang): call ARY_SET_LEN(ary, 0) before
naruse 2011-01-31 05:42:40 +0900 (Mon, 31 Jan 2011) New Revision: 30736 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30736 Log: * 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. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 30735) +++ array.c (revision 30736) @@ -3484,8 +3484,11 @@ if (RARRAY_LEN(ary) == (i = RHASH_SIZE(hash))) { return Qnil; } + ARY_SET_LEN(ary, 0); + if (ARY_SHARED_P(ary) && !ARY_EMBED_P(ary)) { + rb_ary_unshare(ary); + } ary_resize_capa(ary, i); - ARY_SET_LEN(ary, 0); st_foreach(RHASH_TBL(hash), push_value, ary); } else { Index: ChangeLog =================================================================== --- ChangeLog (revision 30735) +++ ChangeLog (revision 30736) @@ -1,3 +1,11 @@ +Mon Jan 31 04:45:12 2011 NARUSE, Yui <naruse@r...> + + * 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. + Sun Jan 30 17:19:46 2011 Tanaka Akira <akr@f...> * missing/crypt.c: parenthesize macro arguments. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/