Skip to content

Commit 2ab6dbd

Browse files
authored
Fix crash on Android 16 security patch September 5 with home widget enabled (#1779)
2 parents 57de93c + 0f8d590 commit 2ab6dbd

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Simplenote/src/main/java/com/automattic/simplenote/NoteListWidgetFactory.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ public NoteListWidgetFactory(Context context, Intent intent) {
3030
mIsLight = intent.getExtras() == null || intent.getExtras().getBoolean(EXTRA_IS_LIGHT, true);
3131
}
3232

33-
@Override
34-
public int getCount() {
35-
return mCursor.getCount();
36-
}
33+
@Override
34+
public int getCount() {
35+
// Defensively check if the cursor is null or closed.
36+
// This prevents a NullPointerException if getCount() is called before
37+
// onDataSetChanged() has finished initializing the cursor.
38+
if (mCursor == null || mCursor.isClosed()) {
39+
return 0;
40+
}
41+
return mCursor.getCount();
42+
}
3743

3844
@Override
3945
public long getItemId(int position) {

0 commit comments

Comments
 (0)