2017-01-05 16:58 GMT+08:00 Bodecs Bela <bode...@vivanet.hu>: > > > 2017.01.05. 9:43 keltezéssel, Steven Liu írta: > >> 2017-01-05 15:47 GMT+08:00 Bodecs Bela <bode...@vivanet.hu>: >> >> >>> 2017.01.05. 1:20 keltezéssel, Steven Liu írta: >>> >>> fix CID: 1398364 Resource leak >>>> refine the code of the new options >>>> >>>> Signed-off-by: Steven Liu <l...@chinaffmpeg.org> >>>> --- >>>> libavformat/hlsenc.c | 21 +++++++++++++-------- >>>> 1 file changed, 13 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >>>> index 808a797..feeb853 100644 >>>> --- a/libavformat/hlsenc.c >>>> +++ b/libavformat/hlsenc.c >>>> @@ -446,11 +446,18 @@ static int hls_append_segment(struct >>>> AVFormatContext *s, HLSContext *hls, double >>>> if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | >>>> HLS_SECOND_LEVEL_SEGMENT_DURATION)) && >>>> strlen(hls->current_segment_final_filename_fmt)) { >>>> char * old_filename = av_strdup(hls->avf->filename); // %%s >>>> will be %s after strftime >>>> + if (!old_filename) { >>>> + av_free(en); >>>> + return AVERROR(ENOMEM); >>>> + } >>>> av_strlcpy(hls->avf->filename, >>>> hls->current_segment_final_filename_fmt, >>>> sizeof(hls->avf->filename)); >>>> + char * filename = av_strdup(hls->avf->filename); // %%s will >>>> be %s after strftime >>>> + if (!filename) { >>>> + av_free(old_filename); >>>> + av_free(en); >>>> + return AVERROR(ENOMEM); >>>> + } >>>> if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) { >>>> - char * filename = av_strdup(hls->avf->filename); // %%s >>>> will be %s after strftime >>>> - if (!filename) >>>> - return AVERROR(ENOMEM); >>>> if (replace_int_data_in_filename(hls->avf->filename, >>>> sizeof(hls->avf->filename), >>>> filename, 's', pos + size) < 1) { >>>> av_log(hls, AV_LOG_ERROR, >>>> @@ -459,14 +466,11 @@ static int hls_append_segment(struct >>>> AVFormatContext *s, HLSContext *hls, double >>>> filename); >>>> av_free(filename); >>>> av_free(old_filename); >>>> + av_free(en); >>>> return AVERROR(EINVAL); >>>> } >>>> - av_free(filename); >>>> } >>>> if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) { >>>> - char * filename = av_strdup(hls->avf->filename); // %%t >>>> will be %t after strftime >>>> - if (!filename) >>>> - return AVERROR(ENOMEM); >>>> if (replace_int_data_in_filename(hls->avf->filename, >>>> sizeof(hls->avf->filename), >>>> filename, 't', (int64_t)round(1000000 * duration)) < >>>> 1) { >>>> av_log(hls, AV_LOG_ERROR, >>>> @@ -475,10 +479,11 @@ static int hls_append_segment(struct >>>> AVFormatContext *s, HLSContext *hls, double >>>> filename); >>>> av_free(filename); >>>> av_free(old_filename); >>>> + av_free(en); >>>> return AVERROR(EINVAL); >>>> } >>>> - av_free(filename); >>>> } >>>> + av_free(filename); >>>> ff_rename(old_filename, hls->avf->filename, hls); >>>> av_free(old_filename); >>>> } >>>> >>>> if you remove av_strdup after if branch, this way if >>> >>> HLS_SECOND_LEVEL_SEGMENT_SIZE and HLS_SECOND_LEVEL_SEGMENT_DURATION also >>> set, only later one will applied because filename will be the original >>> one >>> in second if branch. >>> >>> bb >>> >>> >>> new patch update. >>> >> yes, it os ok now, thank you. > > applied!
Thanks > >> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >>> >>> >>> _______________________________________________ >>> ffmpeg-devel mailing list >>> ffmpeg-devel@ffmpeg.org >>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>> >> > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel