Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -117,10 +117,22 @@ [array removeItemAtIndex: i]; mutations++; [obj release]; + + /* + * We need to get the C array again as it might have + * been relocated. We also need to adjust the count + * as otherwise we would have an out of bounds access. + * As another object will be at the current index now, + * we also need to handle the same index again, thus we + * decrease it. + */ + objs = [array cArray]; + count--; + i--; } } return self; } @@ -134,10 +146,22 @@ if (objs[i] == obj) { [array removeItemAtIndex: i]; mutations++; [obj release]; + + /* + * We need to get the C array again as it might have + * been relocated. We also need to adjust the count + * as otherwise we would have an out of bounds access. + * As another object will be at the current index now, + * we also need to handle the same index again, thus we + * decrease it. + */ + objs = [array cArray]; + count--; + i--; } } return self; }