From 822682caba99e2d4ff4b4d62e6d91bd398ae208b Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Tue, 31 Mar 2020 10:11:59 -0400 Subject: [PATCH] Fix NPE in BitmapUtil.toJpeg() Fixes #9513 --- .../securesms/mediasend/camerax/CameraXUtil.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/mediasend/camerax/CameraXUtil.java b/app/src/main/java/org/thoughtcrime/securesms/mediasend/camerax/CameraXUtil.java index 02b444449d..3f77cd6f9a 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/mediasend/camerax/CameraXUtil.java +++ b/app/src/main/java/org/thoughtcrime/securesms/mediasend/camerax/CameraXUtil.java @@ -77,8 +77,12 @@ public class CameraXUtil { Log.w(TAG, String.format(Locale.ENGLISH, "Decoded image dimensions differed from stated dimensions! Stated: %d x %d, Decoded: %d x %d", image.getWidth(), image.getHeight(), dimens.first, dimens.second)); Log.w(TAG, "Ignoring the stated rotation and rotating the crop rect 90 degrees (stated rotation is " + rotation + " degrees)."); + rotation = 0; - cropRect = new Rect(cropRect.top, cropRect.left, cropRect.bottom, cropRect.right); + + if (cropRect != null) { + cropRect = new Rect(cropRect.top, cropRect.left, cropRect.bottom, cropRect.right); + } } } catch (BitmapDecodingException e) { Log.w(TAG, "Failed to decode!", e);