[FFmpeg-cvslog] avformat/hlsenc: fix memleak in update_variant_stream_info

Steven Liu git at videolan.org
Wed Aug 21 11:46:46 EEST 2019


ffmpeg | branch: master | Steven Liu <lq at chinaffmpeg.org> | Tue Aug 20 10:29:04 2019 +0800| [d1fe1344ea9890a29badd3ff48b600eb5225dca8] | committer: Steven Liu

avformat/hlsenc: fix memleak in update_variant_stream_info

Signed-off-by: Steven Liu <lq at chinaffmpeg.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1fe1344ea9890a29badd3ff48b600eb5225dca8
---

 libavformat/hlsenc.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 836e290eea..c740cf2c56 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2131,14 +2131,18 @@ static int update_variant_stream_info(AVFormatContext *s) {
         hls->var_streams[0].nb_streams = s->nb_streams;
         hls->var_streams[0].streams = av_mallocz(sizeof(AVStream *) *
                                             hls->var_streams[0].nb_streams);
-        if (!hls->var_streams[0].streams)
+        if (!hls->var_streams[0].streams) {
+            av_free(hls->var_streams);
             return AVERROR(ENOMEM);
+        }
 
         //by default, the first available ccgroup is mapped to the variant stream
         if (hls->nb_ccstreams) {
             hls->var_streams[0].ccgroup = av_strdup(hls->cc_streams[0].ccgroup);
-            if (!hls->var_streams[0].ccgroup)
+            if (!hls->var_streams[0].ccgroup) {
+                av_free(hls->var_streams);
                 return AVERROR(ENOMEM);
+            }
         }
 
         for (i = 0; i < s->nb_streams; i++)



More information about the ffmpeg-cvslog mailing list