From 26c270c5d5189618bb67c9e43bdb87ee3d921548 Mon Sep 17 00:00:00 2001 From: Keith Vetter Date: Wed, 30 Oct 2024 12:45:49 -0500 Subject: [PATCH] Fix fft.cpp uninitialized mem warnings found in Ubuntu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- libkoviz/fft.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libkoviz/fft.cpp b/libkoviz/fft.cpp index 9dbdf44..1da008e 100755 --- a/libkoviz/fft.cpp +++ b/libkoviz/fft.cpp @@ -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);