Skip to content

Commit a46a60b

Browse files
MatanZNadeem Anwar
authored andcommitted
Handle another failure path
Avoid crash when BitmapFactory cannot decode image
1 parent 431be1b commit a46a60b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

terminal-emulator/src/main/java/com/termux/terminal/TerminalBitmap.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ public TerminalBitmap(int num, byte[] image, int Y, int X, int cellW, int cellH,
7777
bm = BitmapFactory.decodeByteArray(image, 0, image.length, scaleOptions);
7878
} catch (Exception e) {
7979
Logger.logWarn(null, LOG_TAG, "Out of memory, cannot decode image");
80+
bitmap = null;
81+
return;
82+
}
83+
if (bm == null) {
84+
Logger.logWarn(null, LOG_TAG, "Could not decode image");
85+
bitmap = null;
86+
return;
8087
}
8188
int maxWidth = (screen.mColumns - X) * cellW;
8289
if (newWidth > maxWidth) {

0 commit comments

Comments
 (0)