diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-18 14:24:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-07-18 14:24:48 +0000 |
commit | a6ba688db3ce0376e6661c4aeed340a7ae6eb4fe (patch) | |
tree | 5be6ff3d6cc8a8cbb544ac54b90f5171d21b51c1 | |
parent | d89c7635285b5d0e84400577eedb53349c798f86 (diff) | |
download | ruby-a6ba688db3ce0376e6661c4aeed340a7ae6eb4fe.tar.gz |
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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | array.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -5426,7 +5426,9 @@ rb_ary_any_p(VALUE ary) 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; } |