Commit ae843050 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt Committed by Steven Liu

avformat/hlsenc: Only allocate when data is known to be needed

hls_init() would allocate a buffer, although it is only needed in one of
two branches that follow. This commit moves the allocation to the branch
that actually needs the buffer.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Reviewed-by: 's avatarSteven Liu <lq@onvideo.cn>
parent 728c44b8
......@@ -2906,22 +2906,21 @@ static int hls_init(AVFormatContext *s)
ret = AVERROR(ENOMEM);
goto fail;
}
vs->vtt_m3u8_name = av_malloc(vtt_basename_size);
if (!vs->vtt_m3u8_name ) {
ret = AVERROR(ENOMEM);
goto fail;
}
av_strlcpy(vs->vtt_basename, vs->m3u8_name, vtt_basename_size);
p = strrchr(vs->vtt_basename, '.');
if (p)
*p = '\0';
if ( hls->subtitle_filename ) {
av_freep(&vs->vtt_m3u8_name);
ret = format_name(hls->subtitle_filename, &vs->vtt_m3u8_name, i, vs->varname);
if (ret < 0)
goto fail;
} else {
vs->vtt_m3u8_name = av_malloc(vtt_basename_size);
if (!vs->vtt_m3u8_name) {
ret = AVERROR(ENOMEM);
goto fail;
}
strcpy(vs->vtt_m3u8_name, vs->vtt_basename);
av_strlcat(vs->vtt_m3u8_name, "_vtt.m3u8", vtt_basename_size);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment