summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-18 14:24:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-18 14:24:48 +0000
commita6ba688db3ce0376e6661c4aeed340a7ae6eb4fe (patch)
tree5be6ff3d6cc8a8cbb544ac54b90f5171d21b51c1 /array.c
parentd89c7635285b5d0e84400577eedb53349c798f86 (diff)
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
Diffstat (limited to 'array.c')
-rw-r--r--array.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/array.c b/array.c
index 92897c4cea..5d327bc6be 100644
--- a/array.c
+++ b/array.c
@@ -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;
}