1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avformat/segment: Fix memory leak of cur_entry.filename

Solution suggested-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Lvqier 2015-12-08 19:29:13 +08:00 committed by Michael Niedermayer
parent 7dc469f342
commit 93d336fb07

View File

@ -183,6 +183,7 @@ static int set_segment_filename(AVFormatContext *s)
SegmentContext *seg = s->priv_data;
AVFormatContext *oc = seg->avf;
size_t size;
int ret;
if (seg->segment_idx_wrap)
seg->segment_idx %= seg->segment_idx_wrap;
@ -206,9 +207,8 @@ static int set_segment_filename(AVFormatContext *s)
if (seg->entry_prefix)
size += strlen(seg->entry_prefix);
seg->cur_entry.filename = av_mallocz(size);
if (!seg->cur_entry.filename)
return AVERROR(ENOMEM);
if ((ret = av_reallocp(&seg->cur_entry.filename, size)) < 0)
return ret;
snprintf(seg->cur_entry.filename, size, "%s%s",
seg->entry_prefix ? seg->entry_prefix : "",
av_basename(oc->filename));