[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Thu May 7 16:29:24 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May  7 12:08:26 2015 +0200| [f5e0f948dbd3d256ad8624170999fabfa05204b8] | committer: Geoffrey Métais

Prevent NPE

CID #1297077

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

 vlc-android/src/org/videolan/vlc/MediaDatabase.java |    2 ++
 vlc-android/src/org/videolan/vlc/MediaLibrary.java  |    2 ++
 2 files changed, 4 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index 0deabdb..3936566 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -41,6 +41,7 @@ import android.database.sqlite.SQLiteOpenHelper;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
 import android.net.Uri;
+import android.support.annotation.Nullable;
 import android.util.Log;
 
 public class MediaDatabase {
@@ -421,6 +422,7 @@ public class MediaDatabase {
      * @param playlistName Unique name of the playlist
      * @return Array containing MRLs of the playlist in order, or null on error
      */
+   @Nullable
     public String[] playlistGetItems(String playlistName) {
         if(!playlistExists(playlistName))
             return null;
diff --git a/vlc-android/src/org/videolan/vlc/MediaLibrary.java b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
index 0a28858..1d16ee9 100644
--- a/vlc-android/src/org/videolan/vlc/MediaLibrary.java
+++ b/vlc-android/src/org/videolan/vlc/MediaLibrary.java
@@ -194,6 +194,8 @@ public class MediaLibrary {
         String[] items, playlistNames = db.getPlaylists();
         for (String playlistName : playlistNames){
             items = db.playlistGetItems(playlistName);
+            if (items == null)
+                continue;
             playList = new AudioBrowserListAdapter.ListItem(playlistName, null, null, false);
             for (String track : items){
                 playList.mMediaList.add(new MediaWrapper(track));



More information about the Android mailing list