From bae8844e35147f92e612a9e0b44e939a293e5bc9 Mon Sep 17 00:00:00 2001 From: James Almer Date: Fri, 20 Sep 2019 22:39:09 +0200 Subject: [PATCH] avformat/utils: unref packet on AVInputFormat.read_packet() failure Demuxers may have allocated a packet before encountering an error and aborting. Fixes ticket #8150 Signed-off-by: James Almer --- libavformat/utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index a7f2582e0e..4657ba2642 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -854,6 +854,8 @@ int ff_read_packet(AVFormatContext *s, AVPacket *pkt) av_init_packet(pkt); ret = s->iformat->read_packet(s, pkt); if (ret < 0) { + av_packet_unref(pkt); + /* Some demuxers return FFERROR_REDO when they consume data and discard it (ignored streams, junk, extradata). We must re-call the demuxer to get the real packet. */