Skip to content

Commit

Permalink
receiver object may be changed within NSArray#each_index block
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jul 5, 2012
1 parent 4ea6d4b commit b9f969e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion NSArray.m
Expand Up @@ -479,9 +479,15 @@
nsary_each_index(id rcv, SEL sel)
{
RETURN_ENUMERATOR(rcv, 0, 0);
for (long i = 0, count = [rcv count]; i < count; i++) {
long len = [rcv count];
for (long i = 0; i < len; i++) {
rb_yield(LONG2NUM(i));
RETURN_IF_BROKEN();
const long n = [rcv count];
if (n < len) {
// Array was modified.
len = n;
}
}
return (VALUE)rcv;
}
Expand Down

0 comments on commit b9f969e

Please sign in to comment.