]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/cafdec.c
Do not call parse_keyframes_index with NULL stream.
[ffmpeg] / libavformat / cafdec.c
index 8b0daddd58eeb7040725ca502293d40c2343b0f7..a1d2ff79881746d74456fe867f44f9ce6ba12556 100644 (file)
@@ -292,8 +292,6 @@ static int read_header(AVFormatContext *s,
                                 "block size or frame size are variable.\n");
         return AVERROR_INVALIDDATA;
     }
-    s->file_size = avio_size(pb);
-    s->file_size = FFMAX(0, s->file_size);
 
     av_set_pts_info(st, 64, 1, st->codec->sample_rate);
     st->start_time = 0;
@@ -366,6 +364,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
 {
     AVStream *st = s->streams[0];
     CaffContext *caf = s->priv_data;
+    CaffContext caf2 = *caf;
     int64_t pos;
 
     timestamp = FFMAX(timestamp, 0);
@@ -385,7 +384,10 @@ static int read_seek(AVFormatContext *s, int stream_index,
         return -1;
     }
 
-    avio_seek(s->pb, pos + caf->data_start, SEEK_SET);
+    if (avio_seek(s->pb, pos + caf->data_start, SEEK_SET) < 0) {
+        *caf = caf2;
+        return -1;
+    }
     return 0;
 }