Skip to content

Commit 585f7b9

Browse files
sherginfacebook-github-bot
authored andcommittedNov 29, 2018
Summary:
Calling -[UIScrollView setContentOffset] with NaN values can cause a crash. That's not clear why exactly the computation returns NaN sometime, but the implemented sanitizing should help to detect this problem during development (and this also prevents the app from crashing). See attached task for more details. Reviewed By: fkgozali Differential Revision: D13242729 fbshipit-source-id: 747bf1b42e02597e9f1300eee24547563ab29b27
1 parent d6d31a4 commit 585f7b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎React/Views/ScrollView/RCTScrollView.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,10 @@ - (void)setContentOffset:(CGPoint)contentOffset
303303
contentOffset.y = -(scrollViewSize.height - subviewSize.height) / 2.0;
304304
}
305305
}
306-
super.contentOffset = contentOffset;
306+
307+
super.contentOffset = CGPointMake(
308+
RCTSanitizeNaNValue(contentOffset.x, @"scrollView.contentOffset.x"),
309+
RCTSanitizeNaNValue(contentOffset.y, @"scrollView.contentOffset.y"));
307310
}
308311

309312
- (void)setFrame:(CGRect)frame

0 commit comments

Comments
 (0)
Please sign in to comment.