Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Unified Diff: ios/chrome/browser/ui/collection_view/collection_view_model.mm

Issue 2659593002: Can request CollectionViewModel itemAtIndexPath with nil (Closed)
Patch Set: Add test Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/collection_view/collection_view_model.mm
diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model.mm b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
index d7e388db372a767db11a49c018e409934f766a41..9132bdecbb192dd4fa4ba9d11aaae32f5fcb82a5 100644
--- a/ios/chrome/browser/ui/collection_view/collection_view_model.mm
+++ b/ios/chrome/browser/ui/collection_view/collection_view_model.mm
@@ -147,6 +147,9 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
#pragma mark Query items from index paths
- (BOOL)hasItemAtIndexPath:(NSIndexPath*)indexPath {
+ if (!indexPath)
+ return NO;
+
if (static_cast<NSUInteger>(indexPath.section) < [_sections count]) {
SectionItems* items = [_sections objectAtIndex:indexPath.section];
return static_cast<NSUInteger>(indexPath.item) < [items count];
@@ -155,6 +158,7 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems;
}
- (CollectionViewItem*)itemAtIndexPath:(NSIndexPath*)indexPath {
+ DCHECK(indexPath);
DCHECK_LT(static_cast<NSUInteger>(indexPath.section), [_sections count]);
SectionItems* items = [_sections objectAtIndex:indexPath.section];
« no previous file with comments | « no previous file | ios/chrome/browser/ui/collection_view/collection_view_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698