OSDN Git Service

eleven: fix invalid srt formats
authorJorge Ruesga <jorge@ruesga.com>
Mon, 13 Jul 2015 21:45:47 +0000 (23:45 +0200)
committerJorge Ruesga <jorge@ruesga.com>
Mon, 13 Jul 2015 21:45:47 +0000 (23:45 +0200)
Check for invalid time formats in srt files too. If there is an exception loading the file
just throw out the entire file.

Change-Id: Ic6011f843d1c433e9d8d84281c1c98dc5deaf547
JIRA: NIGHTLIES-1552
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
src/com/cyanogenmod/eleven/utils/SrtParser.java

index a5d4ccc..2b27890 100644 (file)
@@ -89,12 +89,18 @@ public class SrtParser {
 
                 ret.add(entry);
             }
+        } catch (NumberFormatException nfe) {
+            // The file isn't a valid srt format
+            Log.e(TAG, nfe.getMessage(), nfe);
+            ret = null;
         } catch (IOException ioe) {
             // shouldn't happen
             Log.e(TAG, ioe.getMessage(), ioe);
+            ret = null;
         } catch (ArrayIndexOutOfBoundsException e) {
             // if the time is malformed
             Log.e(TAG, e.getMessage());
+            ret = null;
         } finally {
             if (br != null) {
                 try {