[FFmpeg-devel] [PATCH 2/4] avfilter/vf_fftfilt: Check return value of av_tx_init()

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Nov 9 18:37:28 EET 2022


Should fix Coverity issue #1516765.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavfilter/vf_fftfilt.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/libavfilter/vf_fftfilt.c b/libavfilter/vf_fftfilt.c
index 067ce7eb30..231e74fd72 100644
--- a/libavfilter/vf_fftfilt.c
+++ b/libavfilter/vf_fftfilt.c
@@ -306,7 +306,7 @@ static int config_props(AVFilterLink *inlink)
 {
     FFTFILTContext *s = inlink->dst->priv;
     const AVPixFmtDescriptor *desc;
-    int i, plane;
+    int err, i, plane;
 
     desc = av_pix_fmt_desc_get(inlink->format);
     s->depth = desc->comp[0].depth;
@@ -335,12 +335,14 @@ static int config_props(AVFilterLink *inlink)
         for (int j = 0; j < s->nb_threads; j++) {
             float scale = 1.f, iscale = 1.f;
 
-            av_tx_init(&s->hrdft[j][i], &s->htx_fn, AV_TX_FLOAT_RDFT, 0, 1 << s->rdft_hbits[i], &scale, 0);
-            if (!s->hrdft[j][i])
-                return AVERROR(ENOMEM);
-            av_tx_init(&s->ihrdft[j][i], &s->ihtx_fn, AV_TX_FLOAT_RDFT, 1, 1 << s->rdft_hbits[i], &iscale, 0);
-            if (!s->ihrdft[j][i])
-                return AVERROR(ENOMEM);
+            err = av_tx_init(&s->hrdft[j][i], &s->htx_fn, AV_TX_FLOAT_RDFT,
+                             0, 1 << s->rdft_hbits[i], &scale, 0);
+            if (err < 0)
+                return err;
+            err = av_tx_init(&s->ihrdft[j][i], &s->ihtx_fn, AV_TX_FLOAT_RDFT,
+                             1, 1 << s->rdft_hbits[i], &iscale, 0);
+            if (err < 0)
+                return err;
         }
 
         /* RDFT - Array initialization for Vertical pass*/
@@ -356,12 +358,14 @@ static int config_props(AVFilterLink *inlink)
         for (int j = 0; j < s->nb_threads; j++) {
             float scale = 1.f, iscale = 1.f;
 
-            av_tx_init(&s->vrdft[j][i], &s->vtx_fn, AV_TX_FLOAT_RDFT, 0, 1 << s->rdft_vbits[i], &scale, 0);
-            if (!s->vrdft[j][i])
-                return AVERROR(ENOMEM);
-            av_tx_init(&s->ivrdft[j][i], &s->ivtx_fn, AV_TX_FLOAT_RDFT, 1, 1 << s->rdft_vbits[i], &iscale, 0);
-            if (!s->ivrdft[j][i])
-                return AVERROR(ENOMEM);
+            err = av_tx_init(&s->vrdft[j][i], &s->vtx_fn, AV_TX_FLOAT_RDFT,
+                             0, 1 << s->rdft_vbits[i], &scale, 0);
+            if (err < 0)
+                return err;
+            err = av_tx_init(&s->ivrdft[j][i], &s->ivtx_fn, AV_TX_FLOAT_RDFT,
+                             1, 1 << s->rdft_vbits[i], &iscale, 0);
+            if (err < 0)
+                return err;
         }
     }
 
-- 
2.34.1



More information about the ffmpeg-devel mailing list