diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index a2003c6632..7549fc91c9 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -609,8 +609,9 @@ static int get_packet_size(AVFormatContext* s) /*init buffer to store stream for probing */ uint8_t buf[PROBE_PACKET_MAX_BUF] = {0}; int buf_size = 0; + int max_iterations = 16; - while (buf_size < PROBE_PACKET_MAX_BUF) { + while (buf_size < PROBE_PACKET_MAX_BUF && max_iterations--) { ret = avio_read_partial(s->pb, buf + buf_size, PROBE_PACKET_MAX_BUF - buf_size); if (ret < 0) return AVERROR_INVALIDDATA;