diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index c527a94dec..c3912ad2d4 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -884,7 +884,13 @@ parse_subrip_time (const gchar * ts_string, GstClockTime * t) /* make sure we have exactly three digits after he comma */ p = strchr (s, ','); - g_assert (p != NULL); + if (p == NULL) { + /* If there isn't a ',' the timestamp is broken */ + /* https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/532#note_100179 */ + GST_WARNING ("failed to parse subrip timestamp string '%s'", s); + return FALSE; + } + ++p; len = strlen (p); if (len > 3) { diff --git a/tests/check/elements/subparse.c b/tests/check/elements/subparse.c index 0226464979..9b94a24381 100644 --- a/tests/check/elements/subparse.c +++ b/tests/check/elements/subparse.c @@ -182,6 +182,19 @@ static SubParseInputChunk srt_input4[] = { , }; +/* Test broken timestamp */ +static SubParseInputChunk srt_input5[] = { + { + "1\n00:00:01,000 --> 00:00:02,000\nsome text\n\n", + 1 * GST_SECOND, 2 * GST_SECOND, "some text"} + , + { + "2\n00:02:00,000 --> 00:03:0\nsome other text\n\n3\n00:00:03,000 --> 00:00:04,000\nsome more text\n\n", + 3 * GST_SECOND, 4 * GST_SECOND, "some more text"} + , +}; + + static void setup_subparse (void) { @@ -374,6 +387,9 @@ GST_START_TEST (test_srt) /* try with some WebVTT chunks */ test_srt_do_test (srt_input4, 0, G_N_ELEMENTS (srt_input4)); + + /* try with some broken/cut-off timestamp */ + test_srt_do_test (srt_input5, 0, G_N_ELEMENTS (srt_input5)); } GST_END_TEST;