Skip to content

Commit

Permalink
Handle another failure path
Browse files Browse the repository at this point in the history
Avoid crash when BitmapFactory cannot decode image
  • Loading branch information
MatanZ committed Oct 10, 2024
1 parent f94824a commit d1da723
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public TerminalBitmap(int num, byte[] image, int Y, int X, int cellW, int cellH,
bm = BitmapFactory.decodeByteArray(image, 0, image.length, scaleOptions);
} catch (Exception e) {
Logger.logWarn(null, LOG_TAG, "Out of memory, cannot decode image");
bitmap = null;
return;
}
if (bm == null) {
Logger.logWarn(null, LOG_TAG, "Could not decode image");
bitmap = null;
return;
}
int maxWidth = (screen.mColumns - X) * cellW;
if (newWidth > maxWidth) {
Expand Down

0 comments on commit d1da723

Please sign in to comment.