Skip to content

Commit b4c09d7

Browse files
singalsulgirdwood
authored andcommitted
Math: FFT: Fix possible null pointer reference
Cppcheck finds this issue src/math/fft/fft_16.c:23:27: warning: Either the condition '!plan' is redundant or there is possible null pointer dereference: plan. [nullPointerRedundantCheck] struct icomplex16 *inb = plan->inb16; There's same issue with inb and outb in both fft_16.c and fft_32.c Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent b339190 commit b4c09d7

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/math/fft/fft_16.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void fft_execute_16(struct fft_plan *plan, bool ifft)
2020
{
2121
struct icomplex16 tmp1;
2222
struct icomplex16 tmp2;
23-
struct icomplex16 *inb = plan->inb16;
24-
struct icomplex16 *outb = plan->outb16;
23+
struct icomplex16 *inb;
24+
struct icomplex16 *outb;
2525
int depth;
2626
int top;
2727
int bottom;
@@ -32,7 +32,12 @@ void fft_execute_16(struct fft_plan *plan, bool ifft)
3232
int m;
3333
int n;
3434

35-
if (!plan || !plan->bit_reverse_idx || !inb || !outb)
35+
if (!plan || !plan->bit_reverse_idx)
36+
return;
37+
38+
inb = plan->inb16;
39+
outb = plan->outb16;
40+
if (!inb || !outb)
3641
return;
3742

3843
/* convert to complex conjugate for ifft */

src/math/fft/fft_32.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ void fft_execute_32(struct fft_plan *plan, bool ifft)
2121
{
2222
struct icomplex32 tmp1;
2323
struct icomplex32 tmp2;
24-
struct icomplex32 *inb = plan->inb32;
25-
struct icomplex32 *outb = plan->outb32;
24+
struct icomplex32 *inb;
25+
struct icomplex32 *outb;
2626
int depth;
2727
int top;
2828
int bottom;
@@ -33,7 +33,12 @@ void fft_execute_32(struct fft_plan *plan, bool ifft)
3333
int m;
3434
int n;
3535

36-
if (!plan || !plan->bit_reverse_idx || !inb || !outb)
36+
if (!plan || !plan->bit_reverse_idx)
37+
return;
38+
39+
inb = plan->inb32;
40+
outb = plan->outb32;
41+
if (!inb || !outb)
3742
return;
3843

3944
/* convert to complex conjugate for ifft */

0 commit comments

Comments
 (0)