[FFmpeg-devel] [PATCH 2/4] avformat/mpegenc: Fix leak in case trailer is never written

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Mon Feb 15 16:54:21 EET 2021


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/mpegenc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 810dd717ca..1204e57f04 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -1262,6 +1262,11 @@ static void mpeg_mux_deinit(AVFormatContext *ctx)
         StreamInfo *stream = ctx->streams[i]->priv_data;
         if (!stream)
             continue;
+        for (PacketDesc *pkt = stream->predecode_packet; pkt; ) {
+            PacketDesc *tmp = pkt->next;
+            av_free(pkt);
+            pkt = tmp;
+        }
         av_fifo_freep(&stream->fifo);
     }
 }
-- 
2.27.0



More information about the ffmpeg-devel mailing list