Skip to content

Commit

Permalink
avfilter/formats: Simplify cleanup for ff_merge_* functions
Browse files Browse the repository at this point in the history
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; Instead an
av_assert1() has been added to guarantee it to be NULL.

Furthermore, it is unnecessary to av_freep(&ptr) when ptr == NULL.

Reviewed-by: Nicolas George <[email protected]>
Signed-off-by: Andreas Rheinhardt <[email protected]>
  • Loading branch information
mkver committed Aug 12, 2020
1 parent 195a25a commit 9d1bf9c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libavfilter/formats.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ AVFilterFormats *ff_merge_formats(AVFilterFormats *a, AVFilterFormats *b,
return ret;
fail:
if (ret) {
av_freep(&ret->refs);
av_assert1(!ret->refs);
av_freep(&ret->formats);
av_freep(&ret);
}
av_freep(&ret);
return NULL;
}

Expand All @@ -167,10 +167,10 @@ AVFilterFormats *ff_merge_samplerates(AVFilterFormats *a,
return ret;
fail:
if (ret) {
av_freep(&ret->refs);
av_assert1(!ret->refs);
av_freep(&ret->formats);
av_freep(&ret);
}
av_freep(&ret);
return NULL;
}

Expand Down Expand Up @@ -260,10 +260,10 @@ AVFilterChannelLayouts *ff_merge_channel_layouts(AVFilterChannelLayouts *a,

fail:
if (ret) {
av_freep(&ret->refs);
av_assert1(!ret->refs);
av_freep(&ret->channel_layouts);
av_freep(&ret);
}
av_freep(&ret);
return NULL;
}

Expand Down

0 comments on commit 9d1bf9c

Please sign in to comment.