From 934c50fbe07e49391ba27c3469f99bec65e48d39 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Thu, 12 Jul 2018 10:30:27 -0700 Subject: [PATCH] Fix crash in RCTImagePicker on iOS Summary: @public Apparently if you select images really quickly, the app will crash. Reviewed By: shergin Differential Revision: D8796730 fbshipit-source-id: 81a652d9c8997ee9e83bbee3378954a6718a9b5d --- Libraries/CameraRoll/RCTImagePickerManager.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Libraries/CameraRoll/RCTImagePickerManager.m b/Libraries/CameraRoll/RCTImagePickerManager.m index 1ee31752f..4da2a6490 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.m +++ b/Libraries/CameraRoll/RCTImagePickerManager.m @@ -153,6 +153,11 @@ didFinishPickingMediaWithInfo:(NSDictionary *)info - (void)_dismissPicker:(UIImagePickerController *)picker args:(NSArray *)args { NSUInteger index = [_pickers indexOfObject:picker]; + if (index == NSNotFound) { + // This happens if the user selects multiple items in succession. + return; + } + RCTResponseSenderBlock successCallback = _pickerCallbacks[index]; RCTResponseSenderBlock cancelCallback = _pickerCancelCallbacks[index];