[FFmpeg-devel] [PATCH 4/9] avformat/mpegts: make sure mpegts_resync do not run out of the initially requested probe buffer

Marton Balint cus at passwd.hu
Wed Sep 30 00:10:16 EEST 2020


Signed-off-by: Marton Balint <cus at passwd.hu>
---
 libavformat/mpegts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 50d4d5e9bc..432b1c3ea2 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -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);
-- 
2.26.2



More information about the ffmpeg-devel mailing list