]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/pjsdec.c
avcodec/avcodec: Store whether AVCodec->close needs to be called
[ffmpeg] / libavformat / pjsdec.c
index bb587b569a1b7362a33578772c3bfb48fd0d1254..40d820a8d667afa69b0c8e63431daa52bf51e094 100644 (file)
@@ -33,7 +33,7 @@ typedef struct {
     FFDemuxSubtitlesQueue q;
 } PJSContext;
 
-static int pjs_probe(AVProbeData *p)
+static int pjs_probe(const AVProbeData *p)
 {
     char c;
     int64_t start, end;
@@ -55,6 +55,8 @@ static int64_t read_ts(char **line, int *duration)
     if (sscanf(*line, "%"SCNd64",%"SCNd64, &start, &end) == 2) {
         *line += strcspn(*line, "\"");
         *line += !!**line;
+        if (end < start || end - (uint64_t)start > INT_MAX)
+            return AV_NOPTS_VALUE;
         *duration = end - start;
         return start;
     }
@@ -65,7 +67,6 @@ static int pjs_read_header(AVFormatContext *s)
 {
     PJSContext *pjs = s->priv_data;
     AVStream *st = avformat_new_stream(s, NULL);
-    int res = 0;
 
     if (!st)
         return AVERROR(ENOMEM);
@@ -92,8 +93,10 @@ static int pjs_read_header(AVFormatContext *s)
 
             p[strcspn(p, "\"")] = 0;
             sub = ff_subtitles_queue_insert(&pjs->q, p, strlen(p), 0);
-            if (!sub)
+            if (!sub) {
+                ff_subtitles_queue_clean(&pjs->q);
                 return AVERROR(ENOMEM);
+            }
             sub->pos = pos;
             sub->pts = pts_start;
             sub->duration = duration;
@@ -101,7 +104,7 @@ static int pjs_read_header(AVFormatContext *s)
     }
 
     ff_subtitles_queue_finalize(s, &pjs->q);
-    return res;
+    return 0;
 }
 
 static int pjs_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -125,7 +128,7 @@ static int pjs_read_close(AVFormatContext *s)
     return 0;
 }
 
-AVInputFormat ff_pjs_demuxer = {
+const AVInputFormat ff_pjs_demuxer = {
     .name           = "pjs",
     .long_name      = NULL_IF_CONFIG_SMALL("PJS (Phoenix Japanimation Society) subtitles"),
     .priv_data_size = sizeof(PJSContext),