Check for null imageConfig (#4009)

This commit is contained in:
Amit Uttam 2020-03-04 18:10:12 -03:00 committed by GitHub
parent 815e54bc79
commit 7d002ccdf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,8 @@
diff --git a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
index ef62bed..7379605 100644
--- a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
+++ b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
@@ -49,6 +49,7 @@ import java.io.InputStream;
diff --git a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
index ef62bed..7a363af 100644
--- a/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
+++ b/node_modules/react-native-image-picker/android/src/main/java/com/imagepicker/ImagePickerModule.java
@@ -49,6 +49,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.util.List;
@ -10,7 +10,7 @@ index ef62bed..7379605 100644
import com.facebook.react.modules.core.PermissionListener;
import com.facebook.react.modules.core.PermissionAwareActivity;
@@ -69,6 +70,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -69,6 +70,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
public static final int REQUEST_LAUNCH_IMAGE_LIBRARY = 13002;
public static final int REQUEST_LAUNCH_VIDEO_LIBRARY = 13003;
public static final int REQUEST_LAUNCH_VIDEO_CAPTURE = 13004;
@ -18,7 +18,7 @@ index ef62bed..7379605 100644
public static final int REQUEST_PERMISSIONS_FOR_CAMERA = 14001;
public static final int REQUEST_PERMISSIONS_FOR_LIBRARY = 14002;
@@ -266,26 +268,23 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -266,26 +268,23 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
cameraIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDurationLimit);
}
}
@ -37,7 +37,7 @@ index ef62bed..7379605 100644
else
{
requestCode = REQUEST_LAUNCH_IMAGE_CAPTURE;
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
-
- final File original = createNewFile(reactContext, this.options, false);
- imageConfig = imageConfig.withOriginalFile(original);
@ -58,7 +58,7 @@ index ef62bed..7379605 100644
}
if (cameraIntent.resolveActivity(reactContext.getPackageManager()) == null)
@@ -444,14 +443,20 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -444,14 +443,20 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
callback = null;
return;
@ -86,7 +86,21 @@ index ef62bed..7379605 100644
}
final ReadExifResult result = readExifInterface(responseHelper, imageConfig);
@@ -551,7 +556,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -481,6 +486,13 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
else
{
imageConfig = getResizedImage(reactContext, this.options, imageConfig, initialWidth, initialHeight, requestCode);
+ if (imageConfig == null)
+ {
+ responseHelper.invokeError(callback, "Could not read image");
+ callback = null;
+ return;
+ }
+
if (imageConfig.resized == null)
{
removeUselessFiles(requestCode, imageConfig);
@@ -551,7 +563,8 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
{
return callback == null || (cameraCaptureURI == null && requestCode == REQUEST_LAUNCH_IMAGE_CAPTURE)
|| (requestCode != REQUEST_LAUNCH_IMAGE_CAPTURE && requestCode != REQUEST_LAUNCH_IMAGE_LIBRARY
@ -96,7 +110,7 @@ index ef62bed..7379605 100644
}
private void updatedResultResponse(@Nullable final Uri uri,
@@ -571,22 +577,23 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -571,22 +584,23 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@NonNull final Callback callback,
@NonNull final int requestCode)
{
@ -130,7 +144,7 @@ index ef62bed..7379605 100644
if (!permissionsGranted)
{
final Boolean dontAskAgain = ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE) && ActivityCompat.shouldShowRequestPermissionRationale(activity, Manifest.permission.CAMERA);
@@ -641,7 +648,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -641,7 +655,7 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
PERMISSIONS = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
break;
case REQUEST_PERMISSIONS_FOR_CAMERA:
@ -139,7 +153,7 @@ index ef62bed..7379605 100644
break;
default:
PERMISSIONS = new String[]{};
@@ -781,4 +788,22 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
@@ -781,4 +795,22 @@ public class ImagePickerModule extends ReactContextBaseJavaModule
videoDurationLimit = options.getInt("durationLimit");
}
}
@ -162,11 +176,11 @@ index ef62bed..7379605 100644
+ cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, cameraCaptureURI);
+ }
}
diff --git a/node_modules/react-native-image-picker/ios/ImagePickerManager.m b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
index 46b2c11..70bb8a5 100644
--- a/node_modules/react-native-image-picker/ios/ImagePickerManager.m
+++ b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
@@ -460,7 +460,14 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
diff --git a/node_modules/react-native-image-picker/ios/ImagePickerManager.m b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
index 46b2c11..70bb8a5 100644
--- a/node_modules/react-native-image-picker/ios/ImagePickerManager.m
+++ b/node_modules/react-native-image-picker/ios/ImagePickerManager.m
@@ -460,7 +460,14 @@ - (void)imagePickerController:(UIImagePickerController *)picker didFinishPicking
if (videoURL) { // Protect against reported crash
NSError *error = nil;