# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1315357006 0 # Node ID 41a93f9896e3469051aa8d2a199cbec14ff7ea45 # Parent 25bea6526ca1d2a2ba25b7c88d3ab47f63396ac7 Avoid an array out of bounds after container clear on Mac. diff -r 25bea6526ca1 -r 41a93f9896e3 mac/dw.m --- a/mac/dw.m Tue Sep 06 19:53:39 2011 +0000 +++ b/mac/dw.m Wed Sep 07 00:56:46 2011 +0000 @@ -1372,16 +1372,17 @@ if(tvcols && data) { int cols = (int)[tvcols count]; - if(cols) - { - return [data count] / cols; + int total = (int)[data count]; + if(cols && total) + { + return total / cols; } } return 0; } -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow { - if(tvcols) + if(tvcols && data) { int z, col = -1; int count = (int)[tvcols count]; @@ -1397,8 +1398,11 @@ if(col != -1) { int index = (int)(aRow * count) + col; - id this = [data objectAtIndex:index]; - return ([this isKindOfClass:[NSNull class]]) ? nil : this; + if(index < [data count]) + { + id this = [data objectAtIndex:index]; + return ([this isKindOfClass:[NSNull class]]) ? nil : this; + } } } return nil;