From 6b9ce51b6e79538328f6d6aa0d6b2254c7b36c2a Mon Sep 17 00:00:00 2001 From: Michael W Date: Wed, 12 Jul 2017 14:16:42 +0200 Subject: Gallery2: Fix potential crash * A race between deleting and displaying videos seems to report a higher count of videos available than actually accessible. BUGBASH-489 Change-Id: Iac24002feb8701cc4182c3834f663be017b625d5 --- src/com/android/gallery3d/app/AlbumPage.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java index 7f947d8f3..080dfbab4 100644 --- a/src/com/android/gallery3d/app/AlbumPage.java +++ b/src/com/android/gallery3d/app/AlbumPage.java @@ -652,9 +652,14 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster if (mMediaSet == null) return false; int count = mMediaSet.getMediaItemCount(); + ArrayList list; MediaItem item; for (int i = 0; i < count; i++) { - item = mMediaSet.getMediaItem(i, 1).get(0); + list = mMediaSet.getMediaItem(i, 1); + if (list == null) { + continue; + } + item = list.get(0); if (item == null) { continue; } -- cgit v1.2.3