Skip to content

Commit

Permalink
avformat/hlsenc: fix memleak problem about fmp4_init_filename
Browse files Browse the repository at this point in the history
move fmp4_init_filename init in if else for first fmp4_init_filename set
value operation.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
  • Loading branch information
T-bagwell committed Mar 18, 2018
1 parent 10a0436 commit c608669
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libavformat/hlsenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit c608669

Please sign in to comment.