[FFmpeg-devel] [PATCH 4/4] lavf/dashenc: Fix AVDictionary leaks in case of various init errors.

Andrey Semashev andrey.semashev at gmail.com
Tue Nov 20 14:31:48 EET 2018


On 11/18/18 1:55 PM, Jeyapal, Karthick wrote:
> Thanks for sending these excellent patches. The entire patchset looks good to me.
> Also, many thanks for your patience and taking the earlier review comments in the right spirit.

Ping for merging it then?

> On 11/17/18 11:10 PM, Andrey Semashev wrote:
>> ---
>>   libavformat/dashenc.c | 13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index f552503564..2c872f93a1 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -833,12 +833,12 @@ static int write_manifest(AVFormatContext *s, int final)
>>       snprintf(temp_filename, sizeof(temp_filename), use_rename ? "%s.tmp" : "%s", s->url);
>>       set_http_options(&opts, c);
>>       ret = dashenc_io_open(s, &c->mpd_out, temp_filename, &opts);
>> +    av_dict_free(&opts);
>>       if (ret < 0) {
>>           av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename);
>>           return ret;
>>       }
>>       out = c->mpd_out;
>> -    av_dict_free(&opts);
>>       avio_printf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
>>       avio_printf(out, "<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
>>                   "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n"
>> @@ -924,11 +924,11 @@ static int write_manifest(AVFormatContext *s, int final)
>>   
>>           set_http_options(&opts, c);
>>           ret = dashenc_io_open(s, &c->m3u8_out, temp_filename, &opts);
>> +        av_dict_free(&opts);
>>           if (ret < 0) {
>>               av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", temp_filename);
>>               return ret;
>>           }
>> -        av_dict_free(&opts);
>>   
>>           ff_hls_write_playlist_version(c->m3u8_out, 7);
>>   
>> @@ -1122,9 +1122,9 @@ static int dash_init(AVFormatContext *s)
>>           snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
>>           set_http_options(&opts, c);
>>           ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, &opts);
>> +        av_dict_free(&opts);
>>           if (ret < 0)
>>               return ret;
>> -        av_dict_free(&opts);
>>           os->init_start_pos = 0;
>>   
>>           if (c->format_options_str) {
>> @@ -1145,11 +1145,12 @@ static int dash_init(AVFormatContext *s)
>>               av_dict_set_int(&opts, "dash_track_number", i + 1, 0);
>>               av_dict_set_int(&opts, "live", 1, 0);
>>           }
>> -        if ((ret = avformat_init_output(ctx, &opts)) < 0)
>> +        ret = avformat_init_output(ctx, &opts);
>> +        av_dict_free(&opts);
>> +        if (ret < 0)
>>               return ret;
>>           os->ctx_inited = 1;
>>           avio_flush(ctx->pb);
>> -        av_dict_free(&opts);
>>   
>>           av_log(s, AV_LOG_VERBOSE, "Representation %d init segment will be written to: %s\n", i, filename);
>>   
>> @@ -1553,9 +1554,9 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
>>                    use_rename ? "%s.tmp" : "%s", os->full_path);
>>           set_http_options(&opts, c);
>>           ret = dashenc_io_open(s, &os->out, os->temp_path, &opts);
>> +        av_dict_free(&opts);
>>           if (ret < 0)
>>               return ret;
>> -        av_dict_free(&opts);
>>       }
>>   
>>       //write out the data immediately in streaming mode
> 



More information about the ffmpeg-devel mailing list