[FFmpeg-devel] [PATCH 3/5] avformat/hlsenc: fix memleak problem about fmp4_init_filename
Steven Liu
lq at chinaffmpeg.org
Mon Mar 12 08:34:59 EET 2018
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>
---
libavformat/hlsenc.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 7ca4099e7e..ad9f4d3394 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2574,6 +2574,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);
@@ -2607,6 +2614,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) {
@@ -2661,13 +2669,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;
--
2.15.1
More information about the ffmpeg-devel
mailing list