Skip to content

Commit 3c18f4c

Browse files
allenchen1154Allen Chen
andauthored
Prevent NPE in ImageLayer.getBounds() (#2578)
Co-authored-by: Allen Chen <[email protected]>
1 parent ac2599c commit 3c18f4c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lottie/src/main/java/com/airbnb/lottie/model/layer/ImageLayer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ public class ImageLayer extends BaseLayer {
107107
if (lottieDrawable.getMaintainOriginalImageBounds()) {
108108
outBounds.set(0, 0, lottieImageAsset.getWidth() * scale, lottieImageAsset.getHeight() * scale);
109109
} else {
110-
outBounds.set(0, 0, getBitmap().getWidth() * scale, getBitmap().getHeight() * scale);
110+
Bitmap bitmap = getBitmap();
111+
if (bitmap != null) {
112+
outBounds.set(0, 0, bitmap.getWidth() * scale, bitmap.getHeight() * scale);
113+
} else {
114+
// If the bitmap is null, we aren't rendering anything, so set outBounds to an empty rectangle
115+
outBounds.set(0, 0, 0, 0);
116+
}
111117
}
112118
boundsMatrix.mapRect(outBounds);
113119
}

0 commit comments

Comments
 (0)