[Android] Fix IndexOutOfBoundsException on media delete fail

Geoffrey Métais git at videolan.org
Tue Jan 9 15:44:40 CET 2018


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan  9 09:51:49 2018 +0100| [40b3a67206bb2296da9f15c2c52842fa7908aaf2] | committer: Geoffrey Métais

Fix IndexOutOfBoundsException on media delete fail

(cherry picked from commit 5cc334ce561866ee91cab70f533732c845b78829)

> https://code.videolan.org/videolan/vlc-android/commit/40b3a67206bb2296da9f15c2c52842fa7908aaf2
---

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java | 1 +
 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java    | 1 +
 2 files changed, 2 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index df0bb8437..ba21ba18c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -332,6 +332,7 @@ public class AudioBrowserAdapter extends SortableAdapter<MediaLibraryItem, Audio
 
     public void addItem(final int position, final MediaLibraryItem item) {
         final ArrayList<MediaLibraryItem> referenceList = peekLast();
+        if (position < 0 || position >= referenceList.size()) return;
         final ArrayList<MediaLibraryItem> dataList = new ArrayList<>(referenceList);
         dataList.add(position,item);
         update(dataList);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index e3834106a..257205610 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -148,6 +148,7 @@ public class VideoListAdapter extends SortableAdapter<MediaWrapper, VideoListAda
     @MainThread
     public void add(MediaWrapper item, int position) {
         final ArrayList<MediaWrapper> list = new ArrayList<>(peekLast());
+        if (position < 0 || position >= list.size()) return;
         list.add(position, item);
         update(list);
     }



More information about the Android mailing list