From bb22b9ce211c934db628a4ab1669d436864753e3 Mon Sep 17 00:00:00 2001 From: James Almer Date: Sat, 20 Jul 2019 21:47:55 -0300 Subject: [PATCH] avformat/aacdec: resync to the next adts frame on invalid data instead of aborting Should fix ticket #6634 Signed-off-by: James Almer (cherry picked from commit 881e1f5a6227a6fbaf67083d4d4b6caf58ff9892) --- libavformat/aacdec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index 4cd2f9077e..7008340a32 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -133,6 +133,7 @@ static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, fsize; +retry: ret = av_get_packet(s->pb, pkt, ADTS_HEADER_SIZE); if (ret < 0) return ret; @@ -143,7 +144,10 @@ static int adts_aac_read_packet(AVFormatContext *s, AVPacket *pkt) if ((AV_RB16(pkt->data) >> 4) != 0xfff) { av_packet_unref(pkt); - return AVERROR_INVALIDDATA; + ret = adts_aac_resync(s); + if (ret < 0) + return ret; + goto retry; } fsize = (AV_RB32(pkt->data + 3) >> 13) & 0x1FFF;