[Android] Fix IndexOutOfBoundsException on media delete fail

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


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

Fix IndexOutOfBoundsException on media delete fail

> https://code.videolan.org/videolan/vlc-android/commit/5cc334ce561866ee91cab70f533732c845b78829
---

 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 c0df3a9a1..a2930c820 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -333,6 +333,7 @@ public class AudioBrowserAdapter extends SortableAdapter<MediaLibraryItem, Audio
 
     public void addItem(final int position, final MediaLibraryItem item) {
         final List<MediaLibraryItem> referenceList = peekLast();
+        if (position < 0 || position >= referenceList.size()) return;
         final List<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 2f5863fcf..4ad8f091b 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 List<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