[FFmpeg-devel] [PATCH 5/6] avfilter/formats: Simplify cleanup for ff_merge_* functions

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Aug 8 18:45:48 EEST 2020


Nicolas George:
> Andreas Rheinhardt (12020-08-08):
>> Now that the output's refs-array is only allocated once, it is NULL in
>> any error case and therefore needn't be freed at all. Furthermore, it is
>> unnecessary to av_freep(&ptr) when ptr == NULL.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
>> ---
>>  libavfilter/formats.c | 9 +++------
>>  1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavfilter/formats.c b/libavfilter/formats.c
>> index ae44006dfe..e452fd0408 100644
>> --- a/libavfilter/formats.c
>> +++ b/libavfilter/formats.c
>> @@ -141,10 +141,9 @@ AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b,
>>      return ret;
>>  fail:
>>      if (ret) {
> 
>> -        av_freep(&ret->refs);
> 
> It seems fragile. We could easily unmake the change that guarantees that
> refs is NULL, or use fail for another exit later. Maybe add an
> av_assert1()?
> 
Fixed locally.

- Andreas

PS: Is the order of the formats/channel_layouts arrays actually important?


More information about the ffmpeg-devel mailing list