Skip to content

Commit

Permalink
Return nil to avoid crash
Browse files Browse the repository at this point in the history
Summary:
Logiview: https://www.internalfb.com/logview/instagram_ios_crashes/2ece21699d74d3187e8480e2ec0dce14?trace_tab=0&ds=%7B%22start%22%3A%22-1%20day%22%2C%22end%22%3A%22now%22%7D

This crash happens at line 297 in this file, when the `indexPath` is `nil`
early return when `indexPath == nil` to avoid the crash

Differential Revision: D62513388

fbshipit-source-id: 91aef1ab0474563bf639abb1debf9ca1477e64ed
  • Loading branch information
Yiding Wen authored and facebook-github-bot committed Sep 11, 2024
1 parent 2d11c4d commit 5ee2207
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/IGListKit/IGListCollectionViewLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ - (UICollectionViewLayoutAttributes *)layoutAttributesForItemAtIndexPath:(NSInde
return attributes;
}

if (indexPath == nil) {
return nil;
}

// avoid OOB errors
const NSInteger section = indexPath.section;
const NSInteger item = indexPath.item;
Expand Down Expand Up @@ -474,7 +478,7 @@ - (NSString *)_classNameForDelegate:(id<UICollectionViewDelegateFlowLayout>)dele
- (void)_calculateLayoutIfNeeded {
if (_minimumInvalidatedSection == NSNotFound) {
return;
}
}

UICollectionView *collectionView = self.collectionView;
id<UICollectionViewDelegateFlowLayout> delegate = (id<UICollectionViewDelegateFlowLayout>)collectionView.delegate;
Expand Down

0 comments on commit 5ee2207

Please # to comment.