From 82af7c989be42a516f438f162d21f699be297e79 Mon Sep 17 00:00:00 2001 From: Abhinandan Date: Mon, 30 Jul 2018 11:05:34 -0700 Subject: [PATCH] Fix for crash when height or width is nil (#20454) Summary: This PR fixes the issue of height/width being nil in line no 128 of RCTImagePickerManager.m . ` [self _dismissPicker:picker args:tempImageTag ? @[tempImageTag, height, width] : nil]; ` Fixes#20411 Test Plan ---------- To verify the fix , please make the changes to make either height, width or both `nil ` in `- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info` function of RCTImagePickerManager.m , run the code , you will see the error saying , one of the argument is nil from the array . ![crashscenario](https://user-images.githubusercontent.com/763696/43397014-133ae8fc-9421-11e8-9730-c5906cb8dbea.png) ![crashhandledscenario](https://user-images.githubusercontent.com/763696/43397012-130e42f2-9421-11e8-80fc-cb1abaf8197c.png) Now run the code with the fix , it will not crash . Release Notes: -------------- [IOS][BUGFIX][RCTImagePickerManager] - Change in RCTImagePickerManager to handle crashes if height/width is nil . Pull Request resolved: https://github.com/facebook/react-native/pull/20454 Differential Revision: D9061059 Pulled By: hramos fbshipit-source-id: b17f58e411f97f9b904cca0de6c151312c732972 --- Libraries/CameraRoll/RCTImagePickerManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/CameraRoll/RCTImagePickerManager.m b/Libraries/CameraRoll/RCTImagePickerManager.m index 4da2a6490b9504..6273d7bed9c321 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.m +++ b/Libraries/CameraRoll/RCTImagePickerManager.m @@ -123,7 +123,7 @@ - (void)imagePickerController:(UIImagePickerController *)picker // WARNING: Using ImageStoreManager may cause a memory leak because the // image isn't automatically removed from store once we're done using it. [_bridge.imageStoreManager storeImage:originalImage withBlock:^(NSString *tempImageTag) { - [self _dismissPicker:picker args:tempImageTag ? @[tempImageTag, height, width] : nil]; + [self _dismissPicker:picker args:tempImageTag ? @[tempImageTag, RCTNullIfNil(height), RCTNullIfNil(width)] : nil]; }]; }