Skip to content

Commit

Permalink
Fix fft.cpp uninitialized mem warnings found in Ubuntu
Browse files Browse the repository at this point in the history
Here's the warning:
fft.cpp: In function ‘bool Fft_transformBluestein(double*, double*, size_t)’:
fft.cpp:163:31: warning: ‘*cos_table’ may be used uninitialized [-Wmaybe-uninitialized]
  163 |         breal[0] = cos_table[0];
      |                    ~~~~~~~~~~~^
fft.cpp:164:31: warning: ‘*sin_table’ may be used uninitialized [-Wmaybe-uninitialized]
  164 |         bimag[0] = sin_table[0];
      |                    ~~~~~~~~~~~^

Just needed to return if the malloc size is 0.
  • Loading branch information
keithvetter committed Oct 30, 2024
1 parent 46df3ab commit 26c270c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libkoviz/fft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ bool Fft_transformBluestein(double real[], double imag[], size_t n) {
}

// Allocate memory
if ( n <= 0 || m <= 0 ) {
return false;
}
if (FFT_SIZE_MAX / sizeof(double) < n || FFT_SIZE_MAX / sizeof(double) < m)
return false;
size_t size_n = n * sizeof(double);
Expand Down

0 comments on commit 26c270c

Please sign in to comment.