Skip to content

Commit

Permalink
Fix ImageAssetManager.bitmapForId NPE crash (#2117)
Browse files Browse the repository at this point in the history
In Android docs, BitmapFactory.decodeStream may return null so it must be handled correctly.

Co-authored-by: TechQI <TechQI@126.com>
  • Loading branch information
hsrzq and TechQI authored Aug 10, 2022
1 parent adbd366 commit 108b1be
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ public void setDelegate(@Nullable ImageAssetDelegate assetDelegate) {
try {
bitmap = BitmapFactory.decodeStream(is, null, opts);
} catch (IllegalArgumentException e) {
Logger.warning("Unable to decode image.", e);
Logger.warning("Unable to decode image `" + id + "`.", e);
return null;
}
if (bitmap == null) {
Logger.warning("Decoded image `" + id + "` is null.");
return null;
}
bitmap = Utils.resizeBitmapIfNeeded(bitmap, asset.getWidth(), asset.getHeight());
Expand Down

0 comments on commit 108b1be

Please # to comment.