Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 11, 2024

Conversation

yunyh
Copy link
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

Copy link

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

@gpeal gpeal merged commit 255352b into airbnb:master Nov 11, 2024
7 checks passed
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