From 194273f5f50109f21739ab11db944e65cd18f7c0 Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Fri, 12 Feb 2016 09:27:21 -0800 Subject: [PATCH] Fixed hitTest crash due to sticky header out-of-range Reviewed By: javache Differential Revision: D2932227 fb-gh-sync-id: 05d69ec391685dd7e72d3d5f7d56b189a6eab413 shipit-source-id: 05d69ec391685dd7e72d3d5f7d56b189a6eab413 --- React/Views/RCTScrollView.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index 10f2e5ec9..4cc9d4bc8 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -349,8 +349,14 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) { __block UIView *hitView; + NSArray *subviews = [self contentView].reactSubviews; + NSUInteger subviewCount = subviews.count; [_stickyHeaderIndices enumerateIndexesWithOptions:0 usingBlock:^(NSUInteger idx, BOOL *stop) { - UIView *stickyHeader = [self contentView].reactSubviews[idx]; + if (idx >= subviewCount) { + *stop = YES; + return; + } + UIView *stickyHeader = subviews[idx]; CGPoint convertedPoint = [stickyHeader convertPoint:point fromView:self]; hitView = [stickyHeader hitTest:convertedPoint withEvent:event]; *stop = (hitView != nil);