Permalink
Browse files

Fix possible infinite loop in -[AQGridViewData indicesOfCellsInRect:]

  • Loading branch information...
1 parent 5f2ec44 commit 387d399dd1c18ce4e512fed471d2cf4909616108 Clay Bridges committed Jul 6, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 Classes/AQGridViewData.m
View
4 Classes/AQGridViewData.m
@@ -210,7 +210,9 @@ - (NSIndexSet *) indicesOfCellsInRect: (CGRect) aRect
{
CGRect cellRect = [self cellRectAtIndex: i];
- if ( CGRectGetMaxY(cellRect) < CGRectGetMinY(aRect) )
+ // numPerRow must be > 0 or you get an infinite loop
+ // (i becomes 0 - 1 => UINT_MAX; loop UINT_MAX+1 => 0, etc.)
+ if ( CGRectGetMaxY(cellRect) < CGRectGetMinY(aRect) && numPerRow > 0 )
{
// jump forward to the next row
i += (numPerRow - 1);

0 comments on commit 387d399

Please sign in to comment.