summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2017-07-12 14:16:42 +0200
committerLuK1337 <priv.luk@gmail.com>2019-10-21 21:42:08 +0200
commit075c174d7c6ceaa526ba25e160771c8cba6bc393 (patch)
treed0f294064267cf604ada72f7bc1b49d0ec7f19e8
parent22b375c631257d47c8d401dce9e4f24612a3291e (diff)
downloadandroid_packages_apps_Gallery2-075c174d7c6ceaa526ba25e160771c8cba6bc393.tar.gz
android_packages_apps_Gallery2-075c174d7c6ceaa526ba25e160771c8cba6bc393.tar.bz2
android_packages_apps_Gallery2-075c174d7c6ceaa526ba25e160771c8cba6bc393.zip
Gallery2: Fix potential crash
Author: Michael W <baddaemon87@gmail.com> Date: Wed Jul 12 14:16:42 2017 +0200 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 Author: KhabarlakKonstantin <habarlack@gmail.com> Date: Tue Oct 3 11:22:40 2017 +0300 Fix crash after deleting a video on Albums tab getMediaItem can return empty list if no more media items available, break folder processing then Number of items returned by getMediaItem can be inconsistent with getMediaItemCount Change-Id: I7f2abce5d3832a1b2c1fe068b629a3474ed742e2 Change-Id: Ibcaeff698da118f484a6f38528b4a2111a009fdd
-rw-r--r--src/com/android/gallery3d/app/AlbumPage.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/gallery3d/app/AlbumPage.java b/src/com/android/gallery3d/app/AlbumPage.java
index 7f947d8f3..c3ef4c326 100644
--- a/src/com/android/gallery3d/app/AlbumPage.java
+++ b/src/com/android/gallery3d/app/AlbumPage.java
@@ -652,9 +652,17 @@ public class AlbumPage extends ActivityState implements GalleryActionBar.Cluster
if (mMediaSet == null)
return false;
int count = mMediaSet.getMediaItemCount();
+ ArrayList<MediaItem> 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;
+ }
+ if (list.isEmpty()) {
+ break;
+ }
+ item = list.get(0);
if (item == null) {
continue;
}