Index: src/bridge/NSArray_OFArray.m ================================================================== --- src/bridge/NSArray_OFArray.m +++ src/bridge/NSArray_OFArray.m @@ -16,10 +16,12 @@ #import "NSArray_OFArray.h" #import "OFArray.h" #import "OFBridging.h" +#import "OFOutOfRangeException.h" + @implementation NSArray_OFArray - initWithOFArray: (OFArray*)array_ { if ((self = [super init]) != nil) { @try { @@ -30,20 +32,25 @@ } return self; } -- (id)objectAtIndex: (size_t)index +- (id)objectAtIndex: (NSUInteger)index { id object = [array objectAtIndex: index]; if ([object conformsToProtocol: @protocol(OFBridging)]) return [object NSObject]; return object; } -- (size_t)count +- (NSUInteger)count { - return [array count]; + size_t count = [array count]; + + if (count > NSUIntegerMax) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + return (NSUInteger)count; } @end Index: src/bridge/NSDictionary_OFDictionary.m ================================================================== --- src/bridge/NSDictionary_OFDictionary.m +++ src/bridge/NSDictionary_OFDictionary.m @@ -17,10 +17,12 @@ #import "NSDictionary_OFDictionary.h" #import "OFDictionary.h" #import "NSBridging.h" #import "OFBridging.h" + +#import "OFOutOfRangeException.h" @implementation NSDictionary_OFDictionary - initWithOFDictionary: (OFDictionary*)dictionary_ { if ((self = [super init]) != nil) { @@ -47,10 +49,15 @@ return [object NSObject]; return object; } -- (size_t)count +- (NSUInteger)count { - return [dictionary count]; + size_t count = [dictionary count]; + + if (count > NSUIntegerMax) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + return (NSUInteger)count; } @end Index: src/bridge/OFArray_NSArray.m ================================================================== --- src/bridge/OFArray_NSArray.m +++ src/bridge/OFArray_NSArray.m @@ -18,10 +18,11 @@ #import "OFArray_NSArray.h" #import "NSBridging.h" #import "OFInitializationFailedException.h" +#import "OFOutOfRangeException.h" @implementation OFArray_NSArray - initWithNSArray: (NSArray*)array_ { self = [super init]; @@ -40,11 +41,16 @@ return self; } - (id)objectAtIndex: (size_t)index { - id object = [array objectAtIndex: index]; + id object; + + if (index > NSUIntegerMax) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + object = [array objectAtIndex: index]; if ([object conformsToProtocol: @protocol(NSBridging)]) return [object OFObject]; return object;