X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsrtdec.c;h=e9cd6474b0c1477f889dc5961cec04f985a79c62;hb=a11741c293939193657a82e6055a37dfc6ed910c;hp=b35e50fc367bf304fafad061e9196fabbbf3a9a2;hpb=c734b34b044a182e10b4c2ad95a4f9f75aa1d64c;p=ffmpeg diff --git a/libavformat/srtdec.c b/libavformat/srtdec.c index b35e50fc367..e9cd6474b0c 100644 --- a/libavformat/srtdec.c +++ b/libavformat/srtdec.c @@ -41,15 +41,17 @@ static int srt_probe(AVProbeData *p) ff_text_r8(&tr); /* Check if the first non-empty line is a number. We do not check what the - * number is because in practice it can be anything. */ + * number is because in practice it can be anything. + * Also, that number can be followed by random garbage, so we can not + * unfortunately check that we only have a number. */ if (ff_subtitles_read_line(&tr, buf, sizeof(buf)) < 0 || - strtol(buf, &pbuf, 10) < 0 || *pbuf) + strtol(buf, &pbuf, 10) < 0) return 0; /* Check if the next line matches a SRT timestamp */ if (ff_subtitles_read_line(&tr, buf, sizeof(buf)) < 0) return 0; - if (buf[0] >= '0' && buf[1] <= '9' && strstr(buf, " --> ") + if (buf[0] >= '0' && buf[0] <= '9' && strstr(buf, " --> ") && sscanf(buf, "%*d:%*2d:%*2d%*1[,.]%*3d --> %*d:%*2d:%*2d%*1[,.]%3d", &v) == 1) return AVPROBE_SCORE_MAX; @@ -134,7 +136,7 @@ static int srt_read_header(AVFormatContext *s) } } - ff_subtitles_queue_finalize(&srt->q); + ff_subtitles_queue_finalize(s, &srt->q); end: av_bprint_finalize(&buf, NULL);