Skip to content

Commit 2744f38

Browse files
committed
ANDROID: Fix NPE android issue
1 parent 3109a33 commit 2744f38

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/platform/android/app/src/main/java/net/sourceforge/smallbasic/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ private String getExternalStorage() {
792792
} else if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
793793
// https://commonsware.com/blog/2019/06/07/death-external-storage-end-saga.html
794794
File[] dirs = getExternalMediaDirs();
795-
result = dirs[0].getAbsolutePath();
795+
result = dirs != null && dirs.length > 0 ? dirs[0].getAbsolutePath() : getInternalStorage();
796796
} else {
797797
result = getInternalStorage();
798798
}

src/platform/android/jni/display.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void Canvas::fillRect(int left, int top, int width, int height, pixel_t drawColo
8686
break;
8787
} else if (posY >= dtY) {
8888
pixel_t *line = getLine(posY);
89-
for (int x = 0; x < width; x++) {
89+
for (int x = 0; x < width && line; x++) {
9090
int posX = x + left;
9191
if (posX == _w) {
9292
break;

0 commit comments

Comments
 (0)