aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fft.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fft.c b/fft.c
index 87a89c8..b335a47 100644
--- a/fft.c
+++ b/fft.c
@@ -1191,8 +1191,16 @@ static void fht (FLOAT * fz)
INLINE FLOAT atan_table(FLOAT y, FLOAT x) {
int index;
+ double index_d = ATANSCALE * fabs(y/x);
+
+ // Don't cast an infinite to an int, that's undefined behaviour
+ if (isfinite(index_d)) {
+ index = (int)(ATANSCALE * fabs(y/x));
+ }
+ else {
+ index = ATANSIZE-1;
+ }
- index = (int)(ATANSCALE * fabs(y/x));
if (index>=ATANSIZE)
index = ATANSIZE-1;