Skip to content

Loading…

Fixed the array access beyond bounds. #308

Merged
merged 1 commit into from

2 participants

@shu223

It has crashed for some projects with following stacktrace.


NSRangeException: *** -[__NSArrayI objectAtIndex:]: index 3 beyond bounds [0 .. 2]
@ 0 CoreFoundation 0x00007fff87bf8f56 __exceptionPreprocess + 198
@ 1 libobjc.A.dylib 0x00007fff8fac7dee objc_exception_throw + 43
@ 2 CoreFoundation 0x00007fff87ba2370 -[__NSArrayI objectAtIndex:] + 208
@ 3 appledoc 0x00000001053eff60 _mh_execute_header + 155488
...


So, I added the bounds checking.

@tomaz
Owner

Cool, thanks!

@tomaz tomaz merged commit 140fbb3 into tomaz:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 2, 2013
  1. @shu223
Showing with 2 additions and 2 deletions.
  1. +1 −1 Model/GBMethodData.m
  2. +1 −1 Processing/GBCommentsProcessor.m
View
2 Model/GBMethodData.m
@@ -204,7 +204,7 @@ - (BOOL)formatTypesFromArray:(NSArray *)types toArray:(NSMutableArray *)array pr
if (isLast || isPointer) appendSpace = NO;
// We should not add space between components of a protocol (i.e. id<ProtocolName> should be written without any space). Because we've alreay
- if (!isLast && [[types objectAtIndex:idx+1] isEqualToString:@"<"])
+ if (!isLast && idx+1 < [types count] && [[types objectAtIndex:idx+1] isEqualToString:@"<"])
insideProtocol = YES;
else if ([type isEqualToString:@">"])
insideProtocol = NO;
View
2 Processing/GBCommentsProcessor.m
@@ -406,7 +406,7 @@ - (BOOL)processAvailabilityBlockInString:(NSString *)string lines:(NSArray *)lin
if ([components count] == 0) return NO;
// Get data from captures. Index 1 is directive, index 2 description text.
- NSString *description = [components objectAtIndex:3];
+ NSString *description = [components count] > 3 ? [components objectAtIndex:3] : @"";
NSRange range = [string rangeOfString:description];
NSString *prefix = nil;
if (range.location < [string length]) {
Something went wrong with that request. Please try again.