[Android] Search: Fix potential NullDereference

Jean-Baptiste Kempf git at videolan.org
Thu Jul 17 08:19:35 CEST 2014


vlc-ports/android | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Jul 17 07:59:20 2014 +0200| [91d43df16e1aa1aefcf5f4097e76de565e6660c3] | committer: Jean-Baptiste Kempf

Search: Fix potential NullDereference

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

 .../src/org/videolan/vlc/gui/SearchFragment.java   |   22 +++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
index eb23ba5..64a8d27 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SearchFragment.java
@@ -210,17 +210,19 @@ public class SearchFragment extends ListFragment {
 
             // open media in the player
             Media item = (Media) getListView().getItemAtPosition(position);
-            if (item.getType() == Media.TYPE_VIDEO) {
-                VideoPlayerActivity.start(getActivity(), item.getLocation());
-            } else {
-                ArrayList<String> arr = new ArrayList<String>();
-                for (int i = 0; i < getListAdapter().getCount(); i++) {
-                    Media audioItem = (Media) getListAdapter().getItem(i);
-                    if (audioItem.getType() == Media.TYPE_AUDIO)
-                        arr.add(audioItem.getLocation());
+            if (item != null) {
+                if (item.getType() == Media.TYPE_VIDEO) {
+                    VideoPlayerActivity.start(getActivity(), item.getLocation());
+                } else {
+                    ArrayList<String> arr = new ArrayList<String>();
+                    for (int i = 0; i < getListAdapter().getCount(); i++) {
+                        Media audioItem = (Media) getListAdapter().getItem(i);
+                        if (audioItem.getType() == Media.TYPE_AUDIO)
+                            arr.add(audioItem.getLocation());
+                    }
+                    AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
+                    return;
                 }
-                AudioServiceController.getInstance().load(arr, arr.indexOf(item.getLocation()));
-                return;
             }
             super.onListItemClick(l, v, position, id);
 



More information about the Android mailing list