[Android] AudioAlbumFragment: fix potential IndexOutOfBoundsException

Thomas Guillem git at videolan.org
Fri Oct 9 09:39:53 CEST 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct  9 09:35:51 2015 +0200| [f9dbc38d0634c6b09ca7fa85ba07a020ca9ea8c1] | committer: Thomas Guillem

AudioAlbumFragment: fix potential IndexOutOfBoundsException

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=f9dbc38d0634c6b09ca7fa85ba07a020ca9ea8c1
---

 .../src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java        |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
index aaef39c..8afa9b6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumFragment.java
@@ -29,6 +29,7 @@ import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v7.widget.PopupMenu;
+import android.util.Log;
 import android.view.ContextMenu;
 import android.view.LayoutInflater;
 import android.view.Menu;
@@ -183,6 +184,10 @@ public class AudioAlbumFragment extends PlaybackServiceFragment implements Adapt
     private boolean handleContextItemSelected(MenuItem item, int position) {
         int id = item.getItemId();
 
+        if (mMediaList.size() <= position) {
+            Log.e(TAG, "handleContextItemSelected: wrong index. Shouldn't happen !");
+            return true;
+        }
 
         if (id == R.id.audio_list_browser_set_song) {
             AudioUtil.setRingtone(mMediaList.get(position), getActivity());



More information about the Android mailing list