Skip to content

Commit

Permalink
fix(ios): add protection to prevent crashes caused by negative sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg authored and hippy-actions[bot] committed Dec 14, 2023
1 parent 2726c93 commit dd2320d
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,17 @@ - (void)addCellViewToCollectionViewCell:(UICollectionViewCell *)cell atIndexPath
}

#pragma mark - NativeRenderCollectionViewDelegateWaterfallLayout

- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
HippyShadowView *renderObjectView = [_dataSource cellForIndexPath:indexPath];
return renderObjectView.frame.size;
sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
HippyShadowView *shadowView = [_dataSource cellForIndexPath:indexPath];
CGSize itemSize = shadowView.frame.size;
if (itemSize.width < .0 || itemSize.height < .0) {
HippyLogError(@"Negative item size for %@ at %@ of %@", shadowView, indexPath, self);
return CGSizeZero;
}
return shadowView.frame.size;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView
Expand Down

0 comments on commit dd2320d

Please sign in to comment.