Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 3/4] avfilter/af_afir: Check return value of av_tx_init()
Date: Wed,  9 Nov 2022 17:37:29 +0100
Message-ID: <AS8P250MB074479647C2447D50E8E923F8F3E9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB074465F4EB46CDB0AD5182FA8F3E9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

Should fix Coverity issue #1516762.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavfilter/af_afir.c | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index e1fe7d6a64..910999cce7 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -158,6 +158,7 @@ static int init_segment(AVFilterContext *ctx, AudioFIRSegment *seg,
                         int offset, int nb_partitions, int part_size)
 {
     AudioFIRContext *s = ctx->priv;
+    int err;
 
     seg->tx  = av_calloc(ctx->inputs[0]->ch_layout.nb_channels, sizeof(*seg->tx));
     seg->itx = av_calloc(ctx->inputs[0]->ch_layout.nb_channels, sizeof(*seg->itx));
@@ -178,22 +179,29 @@ static int init_segment(AVFilterContext *ctx, AudioFIRSegment *seg,
         return AVERROR(ENOMEM);
 
     for (int ch = 0; ch < ctx->inputs[0]->ch_layout.nb_channels && part_size >= 8; ch++) {
-        double dscale = 1.0, idscale = 1.0 / part_size;
-        float fscale = 1.f, ifscale = 1.f / part_size;
+        union { double d; float f; } scale, iscale;
+        enum AVTXType tx_type;
 
         switch (s->format) {
         case AV_SAMPLE_FMT_FLTP:
-            av_tx_init(&seg->tx[ch],  &seg->tx_fn,  AV_TX_FLOAT_RDFT, 0, 2 * part_size, &fscale,  0);
-            av_tx_init(&seg->itx[ch], &seg->itx_fn, AV_TX_FLOAT_RDFT, 1, 2 * part_size, &ifscale, 0);
+            scale.f  = 1.f;
+            iscale.f = 1.f / part_size;
+            tx_type  = AV_TX_FLOAT_RDFT;
             break;
         case AV_SAMPLE_FMT_DBLP:
-            av_tx_init(&seg->tx[ch],  &seg->tx_fn,  AV_TX_DOUBLE_RDFT, 0, 2 * part_size, &dscale,  0);
-            av_tx_init(&seg->itx[ch], &seg->itx_fn, AV_TX_DOUBLE_RDFT, 1, 2 * part_size, &idscale, 0);
+            scale.d  = 1.0;
+            iscale.d = 1.0 / part_size;
+            tx_type  = AV_TX_DOUBLE_RDFT;
             break;
         }
-
-        if (!seg->tx[ch] || !seg->itx[ch])
-            return AVERROR(ENOMEM);
+        err = av_tx_init(&seg->tx[ch],  &seg->tx_fn,  tx_type,
+                         0, 2 * part_size, &scale,  0);
+        if (err < 0)
+            return err;
+        err = av_tx_init(&seg->itx[ch], &seg->itx_fn, tx_type,
+                         1, 2 * part_size, &iscale, 0);
+        if (err < 0)
+            return err;
     }
 
     seg->sumin  = ff_get_audio_buffer(ctx->inputs[0], seg->fft_length);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2022-11-09 16:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 16:34 [FFmpeg-devel] [PATCH 1/4] avfilter/af_surround: " Andreas Rheinhardt
2022-11-09 16:37 ` [FFmpeg-devel] [PATCH 2/4] avfilter/vf_fftfilt: " Andreas Rheinhardt
2022-11-09 16:37 ` Andreas Rheinhardt [this message]
2022-11-09 16:37 ` [FFmpeg-devel] [PATCH 4/4] avfilter/vf_fftdnoiz: " Andreas Rheinhardt
2022-11-11 17:36 ` [FFmpeg-devel] [PATCH 1/4] avfilter/af_surround: " Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB074479647C2447D50E8E923F8F3E9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git