Commit 5fc42219 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf
Browse files

Fix possible NullDereference

Uri.Decode can return null if input is Null.
ThereforeURItoFile can return Null if input is Null, and so can URIToFileName.
Media.mLocation could be null (that would be stupid though), and
therefore Media.getFileName could be null and getTitle would crash.

Media.getTitle() will now return an empty string and the other cases
will be checked.
parent 91d43df1
......@@ -85,10 +85,12 @@ public class LibVlcUtil {
}
public static File URItoFile(String URI) {
if(URI == null) return null;
return new File(Uri.decode(URI).replace("file://",""));
}
public static String URItoFileName(String URI) {
if(URI == null) return null;
return URItoFile(URI).getName();
}
......
......@@ -356,10 +356,13 @@ public class Media implements Comparable<Media> {
if (mTitle != null && mType != TYPE_VIDEO)
return mTitle;
else {
int end = getFileName().lastIndexOf(".");
String fileName = getFileName();
if (fileName == null)
return new String();
int end = fileName.lastIndexOf(".");
if (end <= 0)
return getFileName();
return getFileName().substring(0, end);
return fileName;
return fileName.substring(0, end);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment