Fix infinite loop in kiss_fft_next_fast_size for n<=0 (issue #121)

kiss_fft_next_fast_size(0) never terminated because the factorization
loop divides m by 2/3/5 forever when m stays 0. Per maintainer decision,
return 1 for n<=0. Add regression test next_fast_size covering n=0,
n<0 and positive inputs.
This commit is contained in:
zhouyunding
2026-10-21 20:05:00 +08:00
parent 2a1f133716
commit 80aec22623
3 changed files with 43 additions and 0 deletions
+2
View File
@@ -411,6 +411,8 @@ void kiss_fft_cleanup(void)
int kiss_fft_next_fast_size(int n)
{
if (n <= 0) /* nothing to factor; avoid infinite loop for n<=0 */
return 1;
while(1) {
int m=n;
while ( (m%2) == 0 ) m/=2;