Skip to content

Commit

Permalink
[ASElementMap] Fix indexPath's section or item is actually negative #…
Browse files Browse the repository at this point in the history
…trivial (#457)

* [ASElementMap] Fix indexPath's section or item is actually negative.

* Small code style changes
  • Loading branch information
Anyewuya authored and nguyenhuy committed Sep 18, 2017
1 parent e330e57 commit d4846dc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/Details/ASElementMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ - (NSString *)description
- (BOOL)sectionIndexIsValid:(NSInteger)section assert:(BOOL)assert
{
NSInteger sectionCount = _sectionsOfItems.count;
if (section >= sectionCount) {
if (section >= sectionCount || section < 0) {
if (assert) {
ASDisplayNodeFailAssert(@"Invalid section index %zd when there are only %zd sections!", section, sectionCount);
}
Expand Down Expand Up @@ -246,7 +246,7 @@ - (BOOL)itemIndexPathIsValid:(NSIndexPath *)indexPath assert:(BOOL)assert item:(

NSInteger itemCount = _sectionsOfItems[section].count;
NSInteger item = indexPath.item;
if (item >= itemCount) {
if (item >= itemCount || item < 0) {
if (assert) {
ASDisplayNodeFailAssert(@"Invalid item index %zd in section %zd which only has %zd items!", item, section, itemCount);
}
Expand Down

0 comments on commit d4846dc

Please sign in to comment.