]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_afir: Fix leak of AVFilterChannelLayout in case of error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 7 Aug 2020 02:58:56 +0000 (04:58 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 19 Aug 2020 22:24:03 +0000 (00:24 +0200)
If an error happens between the allocation of an AVFilterChannelLayout
and its usage (which involves attaching said object to a more permanent
object), the channel layout array leaks. This can simply be fixed by
making sure that nothing is between the allocation and the
aforementioned usage.

Fixes Coverity issue #1250334.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/af_afir.c

index 5ba880f10b8c6244562cb6a5b0de8162d37e1eda..6cbc7a00a15b8e4648b81daf3e6f03d973e7afdd 100644 (file)
@@ -742,14 +742,14 @@ static int query_formats(AVFilterContext *ctx)
     } else {
         AVFilterChannelLayouts *mono = NULL;
 
-        ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO);
-        if (ret)
-            return ret;
-
         if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts)) < 0)
             return ret;
         if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts)) < 0)
             return ret;
+
+        ret = ff_add_channel_layout(&mono, AV_CH_LAYOUT_MONO);
+        if (ret)
+            return ret;
         for (int i = 1; i < ctx->nb_inputs; i++) {
             if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->out_channel_layouts)) < 0)
                 return ret;