[FFmpeg-cvslog] avfilter/formats: Simplify cleanup for ff_merge_* functions

Andreas Rheinhardt git at videolan.org
Wed Aug 12 22:46:16 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Aug  7 04:10:05 2020 +0200| [9d1bf9cffefa2eb57221eb33d5a261750c4bee85] | committer: Andreas Rheinhardt

avfilter/formats: Simplify cleanup for ff_merge_* functions

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 <george at nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9d1bf9cffefa2eb57221eb33d5a261750c4bee85
---

 libavfilter/formats.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 7099949d5c..3c7f099a94 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -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;
 }
 
@@ -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;
 }
 
@@ -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;
 }
 



More information about the ffmpeg-cvslog mailing list