ruby-changes:34785
From: nobu <ko1@a...>
Date: Fri, 18 Jul 2014 23:25:07 +0900 (JST)
Subject: [ruby-changes:34785] nobu:r46868 (trunk): array.c: array may be modified in the block
nobu 2014-07-18 23:24:48 +0900 (Fri, 18 Jul 2014) New Revision: 46868 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46868 Log: array.c: array may be modified in the block * array.c (rb_ary_any_p): the array may be modified in the yielded block, do not access directly. Modified files: trunk/array.c Index: array.c =================================================================== --- array.c (revision 46867) +++ array.c (revision 46868) @@ -5426,7 +5426,9 @@ rb_ary_any_p(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5426 for (i = 0; i < len; ++i) if (RTEST(ptr[i])) return Qtrue; } else { - for (i = 0; i < len; ++i) if (RTEST(rb_yield(ptr[i]))) return Qtrue; + for (i = 0; i < RARRAY_LEN(ary); ++i) { + if (RTEST(rb_yield(RARRAY_AREF(ary, i)))) return Qtrue; + } } return Qfalse; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/