]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mpegts: make sure mpegts_resync do not run out of the initially requested...
authorMarton Balint <cus@passwd.hu>
Sat, 26 Sep 2020 18:30:27 +0000 (20:30 +0200)
committerMarton Balint <cus@passwd.hu>
Fri, 9 Oct 2020 19:07:18 +0000 (21:07 +0200)
Signed-off-by: Marton Balint <cus@passwd.hu>
libavformat/mpegts.c

index 50d4d5e9bc6b8853a5eb220cfac3d1caf89d15de..432b1c3ea2632fa0219ad74cd8c08476d12928c3 100644 (file)
@@ -3051,10 +3051,11 @@ static int mpegts_read_header(AVFormatContext *s)
     MpegTSContext *ts = s->priv_data;
     AVIOContext *pb   = s->pb;
     int64_t pos, probesize = s->probesize;
+    int64_t seekback = FFMAX(s->probesize, (int64_t)ts->resync_size + PROBE_PACKET_MAX_BUF);
 
     s->internal->prefer_codec_framerate = 1;
 
-    if (ffio_ensure_seekback(pb, probesize) < 0)
+    if (ffio_ensure_seekback(pb, seekback) < 0)
         av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n");
 
     pos = avio_tell(pb);