[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Tue Feb 17 17:43:47 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 17 12:28:54 2015 +0100| [f7c5e36fe1172e4cf27ec4455ac4667d4f7c11aa] | committer: Geoffrey Métais

Prevent NPE

CID  #1270667

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

 .../src/org/videolan/vlc/gui/video/MediaInfoFragment.java   |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 8842ddc..15df4d8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -167,9 +167,14 @@ public class MediaInfoFragment extends ListFragment {
             if (!subFolder.exists())
                 continue;
             String[] subFiles = subFolder.list();
-            String[] newFiles = new String[files.length+subFiles.length];
-            System.arraycopy(subFiles, 0, newFiles, 0, subFiles.length);
-            System.arraycopy(files, 0, newFiles, subFiles.length, files.length);
+            int subFilesLength = 0;
+            String[] newFiles = new String[0];
+            if (subFiles != null) {
+                subFilesLength = subFiles.length;
+                newFiles = new String[files.length+subFilesLength];
+                System.arraycopy(subFiles, 0, newFiles, 0, subFilesLength);
+            }
+            System.arraycopy(files, 0, newFiles, subFilesLength, files.length);
             files = newFiles;
         }
         for (int i = 0; i<files.length ; ++i){



More information about the Android mailing list