Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Frameworks/Foundation/NSArray.mm
Original file line number Diff line number Diff line change
Expand Up @@ -818,14 +818,22 @@ - (NSUInteger)hash {
@Status Interoperable
*/
- (NSArray*)objectsAtIndexes:(NSIndexSet*)indexes {
unsigned idx = [indexes firstIndex];
id ret = [NSMutableArray array];
unsigned count = [self count];
NS_COLLECTION_THROW_IF_NULL_REASON(indexes, @"indexes must not be nil”);
NSUInteger idx = NSNotFound;
id ret = nil;
NSUInteger count = [self count];

if (indexes == nil)
[NSException raise:NSInvalidArgumentException format:@"No index set"];
else {
ret = [NSMutableArray array];
idx = [indexes firstIndex];
}

while (idx != NSNotFound) {
if (idx >= count) {
TraceCritical(TAG, L"objectsAtIndexes: index > count (%d > %d), throwing exception", idx, count);
[NSException raise:@"Array out of bounds" format:@""];
[NSException raise:NSRangeException format:@"Index out of bounds"];
return nil;
}
[ret addObject:[self objectAtIndex:idx]];
Expand Down