[Android] Avoid NPE
Geoffrey Métais
git at videolan.org
Wed Feb 18 11:13:03 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Feb 18 10:47:53 2015 +0100| [7c506ae139903a7d19590ea70cc43b539a324943] | committer: Geoffrey Métais
Avoid NPE
CID #1270667
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=7c506ae139903a7d19590ea70cc43b539a324943
---
.../src/org/videolan/vlc/gui/video/MediaInfoFragment.java | 9 ++++++---
1 file changed, 6 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 15df4d8..c699c98 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -162,6 +162,7 @@ public class MediaInfoFragment extends ListFragment {
videoName = videoName.substring(0, videoName.lastIndexOf('.'));
String[] subFolders = {"/Subtitles", "/subtitles", "/Subs", "/subs"};
String[] files = itemFile.getParentFile().list();
+ int filesLength = files == null ? 0 : files.length;
for (int i = 0 ; i < subFolders.length ; ++i){
File subFolder = new File(parentPath+subFolders[i]);
if (!subFolder.exists())
@@ -171,13 +172,15 @@ public class MediaInfoFragment extends ListFragment {
String[] newFiles = new String[0];
if (subFiles != null) {
subFilesLength = subFiles.length;
- newFiles = new String[files.length+subFilesLength];
+ newFiles = new String[filesLength+subFilesLength];
System.arraycopy(subFiles, 0, newFiles, 0, subFilesLength);
}
- System.arraycopy(files, 0, newFiles, subFilesLength, files.length);
+ if (files != null)
+ System.arraycopy(files, 0, newFiles, subFilesLength, filesLength);
files = newFiles;
+ filesLength = files == null ? 0 : files.length;
}
- for (int i = 0; i<files.length ; ++i){
+ for (int i = 0; i<filesLength ; ++i){
filename = Uri.decode(files[i]);
int index = filename.lastIndexOf('.');
if (index <= 0)
More information about the Android
mailing list