Skip to content

Fix NPE a Bitmap reference at the Utils.resizeBitmapIfNeeded#2573

Merged
gpeal merged 3 commits intoairbnb:masterfrom
yunyh:master
Nov 11, 2024
Merged

Fix NPE a Bitmap reference at the Utils.resizeBitmapIfNeeded#2573
gpeal merged 3 commits intoairbnb:masterfrom
yunyh:master

Conversation

@yunyh
Copy link
Copy Markdown
Contributor

@yunyh yunyh commented Nov 8, 2024

Occur NPE in the Utils.resizeBitmapIfNeeded if referenced Bitmap is null object.

Code modify similar way ImageAssetManager.bitmapForId method (line 138~148)

java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference
        at com.airbnb.lottie.utils.Utils.resizeBitmapIfNeeded(Utils:284)
        at com.airbnb.lottie.manager.ImageAssetManager.bitmapForId(ImageAssetManager:110)
        at com.airbnb.lottie.LottieDrawable.getBitmapForId(LottieDrawable:1564)
        at com.airbnb.lottie.model.layer.ImageLayer.getBitmap(ImageLayer:125)
        at com.airbnb.lottie.model.layer.ImageLayer.drawLayer(ImageLayer:49)
        at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer:270)
        at com.airbnb.lottie.model.layer.CompositionLayer.drawLayer(CompositionLayer:161)
        at com.airbnb.lottie.model.layer.BaseLayer.draw(BaseLayer:270)
        at com.airbnb.lottie.LottieDrawable.drawDirectlyToCanvas(LottieDrawable:1751)
        at com.airbnb.lottie.LottieDrawable.draw(LottieDrawable:758)
        at android.widget.ImageView.onDraw(ImageView.java:1446)

And added null check everywhere use Utils.resizeBitmapIfNeeded

@github-actions
Copy link
Copy Markdown

Snapshot Tests
API 23: Report Diff
API 31: Report Diff

@gpeal gpeal merged commit 255352b into airbnb:master Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants