From 866a7b338160c3bfa1076f9f09adc16b4b20ba71 Mon Sep 17 00:00:00 2001 From: Allen Chen Date: Fri, 15 Nov 2024 12:26:23 -0800 Subject: [PATCH] Prevent NPE in ImageLayer.getBounds() The recent [improvements to drop shadows](https://github.com/airbnb/lottie-android/pull/2548/files#diff-31e777f53a917d69dcf1b234ae6c77db843316c34911e200d0a9a160c058b621R110) added a dereference of a nullable result from the `getBitmap()` call. --- .../main/java/com/airbnb/lottie/model/layer/ImageLayer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lottie/src/main/java/com/airbnb/lottie/model/layer/ImageLayer.java b/lottie/src/main/java/com/airbnb/lottie/model/layer/ImageLayer.java index bb757a3169..ef52cd8dca 100644 --- a/lottie/src/main/java/com/airbnb/lottie/model/layer/ImageLayer.java +++ b/lottie/src/main/java/com/airbnb/lottie/model/layer/ImageLayer.java @@ -107,7 +107,10 @@ public class ImageLayer extends BaseLayer { if (lottieDrawable.getMaintainOriginalImageBounds()) { outBounds.set(0, 0, lottieImageAsset.getWidth() * scale, lottieImageAsset.getHeight() * scale); } else { - outBounds.set(0, 0, getBitmap().getWidth() * scale, getBitmap().getHeight() * scale); + Bitmap bitmap = getBitmap(); + if (bitmap != null) { + outBounds.set(0, 0, bitmap.getWidth() * scale, bitmap.getHeight() * scale); + } } boundsMatrix.mapRect(outBounds); }