[FFmpeg-cvslog] avfilter/af_surround: Fix memleaks upon allocation error

Andreas Rheinhardt git at videolan.org
Wed Jan 12 02:50:36 EET 2022


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Oct  6 15:29:32 2021 +0200| [952c62f658a58f2047ea7e2506d59c0947755f35] | committer: Andreas Rheinhardt

avfilter/af_surround: Fix memleaks upon allocation error

Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
(cherry picked from commit 0429d8eed85674ae19cccab81f7fbb13a4ccc705)

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

 libavfilter/af_surround.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c
index d18b3146e7..c0b8b002c2 100644
--- a/libavfilter/af_surround.c
+++ b/libavfilter/af_surround.c
@@ -203,13 +203,13 @@ static int config_input(AVFilterLink *inlink)
     s->rdft = av_calloc(inlink->channels, sizeof(*s->rdft));
     if (!s->rdft)
         return AVERROR(ENOMEM);
+    s->nb_in_channels = inlink->channels;
 
     for (ch = 0; ch < inlink->channels; ch++) {
         s->rdft[ch]  = av_rdft_init(ff_log2(s->buf_size), DFT_R2C);
         if (!s->rdft[ch])
             return AVERROR(ENOMEM);
     }
-    s->nb_in_channels = inlink->channels;
     s->input_levels = av_malloc_array(s->nb_in_channels, sizeof(*s->input_levels));
     if (!s->input_levels)
         return AVERROR(ENOMEM);
@@ -266,13 +266,13 @@ static int config_output(AVFilterLink *outlink)
     s->irdft = av_calloc(outlink->channels, sizeof(*s->irdft));
     if (!s->irdft)
         return AVERROR(ENOMEM);
+    s->nb_out_channels = outlink->channels;
 
     for (ch = 0; ch < outlink->channels; ch++) {
         s->irdft[ch] = av_rdft_init(ff_log2(s->buf_size), IDFT_C2R);
         if (!s->irdft[ch])
             return AVERROR(ENOMEM);
     }
-    s->nb_out_channels = outlink->channels;
     s->output_levels = av_malloc_array(s->nb_out_channels, sizeof(*s->output_levels));
     if (!s->output_levels)
         return AVERROR(ENOMEM);



More information about the ffmpeg-cvslog mailing list