Skip to content

WebVTTCueParser Matcher and NullPointerException #3228

@q-litzler

Description

@q-litzler

Issue description

It is possible to encounter a NPE here, when secondLine is null.

secondLine can be null when the subtitle file is not well formatted.

Here is a link to the RegexMatcher behavior regarding null arguments.

Proposed solution: Handle the NPE gracefully, somehow.

Reproduction steps

This is happening in production of our app, and sadly I can't pinpoint the corrupted .vtt file on our end. (I would have to check hours of content in 10 different languages ..). If I find it, I will update this issue with a link to test content.

Link to test content

See above

Version of ExoPlayer being used

2.5.1

Device(s) and version(s) of Android being used

All versions from 5.0 to 7.1.2. Wide range of devices. (This is happening in production)

A full bug report captured from the device

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'int java.lang.CharSequence.length()' on a null object reference
       at java.util.regex.Matcher.reset(Matcher.java:995)
       at java.util.regex.Matcher.<init>(Matcher.java:174)
       at java.util.regex.Pattern.matcher(Pattern.java:1006)
       at com.google.android.exoplayer2.text.webvtt.WebvttCueParser.parseCue(WebvttCueParser.java:102)
       at com.google.android.exoplayer2.text.webvtt.WebvttDecoder.decode(WebvttDecoder.java:83)
       at com.google.android.exoplayer2.text.webvtt.WebvttDecoder.decode(WebvttDecoder.java:30)
       at com.google.android.exoplayer2.text.SimpleSubtitleDecoder.decode(SimpleSubtitleDecoder.java:70)
       at com.google.android.exoplayer2.text.SimpleSubtitleDecoder.decode(SimpleSubtitleDecoder.java:25)
       at com.google.android.exoplayer2.decoder.SimpleDecoder.decode(SimpleDecoder.java:222)
       at com.google.android.exoplayer2.decoder.SimpleDecoder.run(SimpleDecoder.java:188)
       at com.google.android.exoplayer2.decoder.SimpleDecoder.access$000(SimpleDecoder.java:25)
       at com.google.android.exoplayer2.decoder.SimpleDecoder$1.run(SimpleDecoder.java:66)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions