[FFmpeg-cvslog] avformat/hlsenc: fix memleak problem about fmp4_init_filename

Steven Liu git at videolan.org
Sun Mar 18 13:06:14 EET 2018


ffmpeg | branch: master | Steven Liu <lq at chinaffmpeg.org> | Sun Mar 18 14:08:14 2018 +0800| [c6086692645951264a4f98a3568f80b7c827a129] | committer: Steven Liu

avformat/hlsenc: fix memleak problem about fmp4_init_filename

move fmp4_init_filename init in if else for first fmp4_init_filename set
value operation.

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

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 2271cedbfc..d64755436e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2576,6 +2576,13 @@ static int hls_init(AVFormatContext *s)
         if (hls->segment_type == SEGMENT_TYPE_FMP4) {
             if (hls->nb_varstreams > 1)
                 fmp4_init_filename_len += strlen(POSTFIX_PATTERN);
+            if (hls->flags & HLS_SINGLE_FILE) {
+                vs->fmp4_init_filename  = av_strdup(vs->basename);
+                if (!vs->fmp4_init_filename) {
+                    ret = AVERROR(ENOMEM);
+                    goto fail;
+                }
+            } else {
             vs->fmp4_init_filename = av_malloc(fmp4_init_filename_len);
             if (!vs->fmp4_init_filename ) {
                 ret = AVERROR(ENOMEM);
@@ -2609,6 +2616,7 @@ static int hls_init(AVFormatContext *s)
                 av_strlcpy(vs->base_output_dirname, vs->fmp4_init_filename,
                            fmp4_init_filename_len);
             }
+            }
         }
 
         if (!hls->use_localtime) {
@@ -2663,13 +2671,6 @@ static int hls_init(AVFormatContext *s)
             }
         }
 
-        if ((hls->flags & HLS_SINGLE_FILE) && (hls->segment_type == SEGMENT_TYPE_FMP4)) {
-            vs->fmp4_init_filename  = av_strdup(vs->basename);
-            if (!vs->fmp4_init_filename) {
-                ret = AVERROR(ENOMEM);
-                goto fail;
-            }
-        }
         if ((ret = hls_mux_init(s, vs)) < 0)
             goto fail;
 



More information about the ffmpeg-cvslog mailing list