[FFmpeg-devel] [PATCH] avformat/hlsenc: Fix memleak when using single_file

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Wed Sep 11 15:36:36 EEST 2019


This commit fixes a memleak in the hls muxer when one uses a single file
as output. It has been forgotten to free the temporary buffers used to write
the packets so that the size of the leaks basically amounts to the size
of the output file. This commit adds the necessary free.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
I used av_freep instead of av_free (as happens in other places) in order
not to leave an inconsistent state behind. There is actually no reason
to keep the pointer to the temporary buffer; an automatic variable would
be enough.
Furthermore, if flush_dynbuf fails at opening a new dynamic buffer, the
temporary buffer needs to be freed nevertheless. Yet this isn't done for
the other two calls to flush_dynbuf.

 libavformat/hlsenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f881bb9d60..a6a3947ac7 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2365,6 +2365,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
 
         if (hls->flags & HLS_SINGLE_FILE) {
             ret = flush_dynbuf(vs, &range_length);
+            av_freep(&vs->temp_buffer);
             if (ret < 0) {
                 return ret;
             }
-- 
2.21.0



More information about the ffmpeg-devel mailing list