Skip to content

Commit

Permalink
[fix #122] receiver object may be changed within NSArray#each block
Browse files Browse the repository at this point in the history
  • Loading branch information
Watson1978 committed Jul 5, 2012
1 parent 85f5996 commit 4ea6d4b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions NSArray.m
Expand Up @@ -462,9 +462,15 @@
nsary_each(id rcv, SEL sel)
{
RETURN_ENUMERATOR(rcv, 0, 0);
for (id item in rcv) {
rb_yield(OC2RB(item));
long len = [rcv count];
for (long i = 0; i < len; i++) {
rb_yield(OC2RB([rcv objectAtIndex: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 4ea6d4b

Please sign in to comment.