Commit Graph
436 Commits
Author SHA1 Message Date
Davide FacontiandClaude Opus 5.5 f519878387 allocators: route all library allocations through KISS_FFT_MALLOC/FREE
Users can override KISS_FFT_MALLOC and KISS_FFT_FREE, but several
places bypassed them:

- kiss_fftnd_alloc and kiss_fftndr_alloc called malloc() directly,
  so their configs (released with kiss_fft_free / kiss_fftndr_free)
  went to a different allocator than the one that freed them.
- kiss_fftndr_free was defined as plain free.
- kfc_cleanup released KISS_FFT_MALLOC'd cache entries with free().
- Under USE_SIMD, KISS_FFT_ALIGN_CHECK and KISS_FFT_ALIGN_SIZE_UP were
  defined only inside "#ifndef KISS_FFT_MALLOC", so overriding the
  allocator broke the build. Define them unconditionally.

Note that under USE_SIMD the nd/ndr configs now come from the SIMD
default allocator (_mm_malloc / aligned_alloc) instead of malloc, so
they must be released with kiss_fft_free / kiss_fftndr_free.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
2026-11-15 20:03:51 +01:00
Davide FacontiandClaude Opus 5.5 c2f367e286 kiss_fftnd, kiss_fftndr: align every object packed into the state block
kiss_fftnd_alloc and kiss_fftndr_alloc carve several objects out of one
allocation, advancing by KISS_FFT_ALIGN_SIZE_UP(size), which is the
identity outside SIMD builds. So objects started at whatever offset the
previous one ended:

- kiss_fftnd: after an odd number of int dims, tmpbuf and the
  per-dimension kiss_fft_state objects were 4 bytes off, misaligned for
  double.
- kiss_fftndr: the nd state (which holds pointers) followed the real-FFT
  state, whose size is only a multiple of 4 for int16_t.

These are misaligned accesses (undefined behavior; SIGBUS on strict
platforms, silent on x86). Add KISS_FFT_PACK_SIZE_UP to
_kiss_fft_guts.h, which rounds a size up to a multiple of the size of a
union of pointer, int and kiss_fft_cpx (a multiple of each of their
alignments, and of the SIMD vector alignment), and use it for every
object in both layouts. The reported sizes grow by a few bytes of padding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
2026-11-15 20:03:51 +01:00
Davide FacontiandClaude Opus 5.5 933c235c1c kiss_fftndr: fix allocation size check, odd sizes and ndims == 1
kiss_fftndr_alloc had three problems:

- Its overflow check divided the required size (truncated to an int) by
  every dimension and failed when fewer than sizeof(kiss_fft_scalar)
  bytes per element remained. The buffers only need slightly more than
  that per element, so valid sizes were rejected: 230 of the even NxN
  sizes from 2 to 512 (starting at 54x54) returned NULL. Replace it with
  a direct check that dimOther*(dimReal+2) scalars fit in size_t with a
  margin and that dimOther fits the int that kiss_fftnd counts it in,
  and make prod() saturate instead of wrapping.

- An odd last dimension is not supported by kiss_fftr, but the failure
  of the kiss_fftr_alloc size query was ignored and a config with a
  NULL kiss_fftr state was returned. Now kiss_fftndr_alloc returns NULL.

- With ndims == 1 the inner kiss_fftnd has zero dimensions, and
  kiss_fftnd never wrote its output in that case (the even-ndims path
  leaves the result in tmpbuf and the loop body never runs), so
  kiss_fftndr/kiss_fftndri returned garbage. Make a zero-dimensional
  kiss_fftnd the identity, which fixes both directions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
2026-11-15 20:02:21 +01:00
mborgerdingandGitHub 57a701785b Merge pull request #145 from facontidavide/fix/size-validation
[fix 1/8] kiss_fft: validate sizes in the alloc functions and next_fast_size
2026-11-15 13:29:49 -05:00
Davide FacontiandClaude Opus 5.5 24fa326186 kiss_fft: validate sizes in the alloc functions and next_fast_size
- kiss_fft_alloc(0) passed the overflow check and computed
  sizeof(kiss_fft_cpx)*(nfft-1) with nfft-1 == -1, returning a config.
  Reject nfft <= 0 (negative sizes were only rejected by accident of the
  signed/unsigned comparison, which is now an explicit cast).
- kiss_fftr_alloc(0) halved 0 and built a config around a NULL
  sub-state. Reject nfft <= 0 along with odd sizes, and compute
  nfft*3/2 in size_t.
- kiss_fftnd_alloc multiplied the dimensions in an int, so {65536,65536}
  wrapped to 0 and {46342,46342} to a negative value: the size query
  reported a bogus size and a far too small buffer was accepted. Reject
  dims <= 0 and products that do not fit in an int (st->dimprod) or whose
  buffer size overflows size_t, reporting *lenmem = (size_t)-1 as
  kiss_fftndr_alloc does.
- kiss_fft_next_fast_size incremented n past INT_MAX for
  n > 2125764000 (the largest 2,3,5-smooth int) and returned a negative
  value. It now returns n itself there (documented in kiss_fft.h): no
  2,3,5-smooth int >= n exists, and n is still a valid, if slower, size
  for callers that pass the result straight to an alloc.
- kfc.c read an uninitialized length when the size query rejected nfft;
  it now returns NULL for an invalid size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ
2026-11-11 10:12:39 +01:00
mborgerdingandGitHub f3fd3a58f1 Merge pull request #123 from sheldonrobinson/master
Add MSVC support for OpenMP in CMakeLists
2026-10-26 07:10:15 -04:00
Sheldon RobinsonandGitHub efb3ccf206 Merge branch 'mborgerding:master' into master 2026-10-25 22:51:12 -04:00
mborgerdingandGitHub 5399a98411 Merge pull request #135 from zhouyunding/work/issue-121
Fix infinite loop in kiss_fft_next_fast_size for n<=0 (issue #121)
2026-10-21 11:38:41 -04:00
zhouyunding 80aec22623 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.
2026-10-21 20:05:00 +08:00
mborgerdingandGitHub 2a1f133716 Merge pull request #134 from ac1982/docs/transform-normalization
docs: explain forward and inverse normalization
2026-10-20 10:07:58 -04:00
AC d3a85a9e01 docs: explain forward and inverse normalization 2026-10-19 11:51:48 +08:00
mborgerdingandGitHub 45b3ad4c08 Merge pull request #132 from farchord/master
Fixing licenses, adding used ones from source files
2026-10-16 08:14:52 -04:00
Steve Cossette d7fc2c3ca2 Fixing licenses, adding used ones from source files 2026-10-15 10:11:59 -04:00
Sheldon RobinsonandGitHub 701a308f51 Merge branch 'mborgerding:master' into master 2026-09-17 07:37:43 -04:00
mborgerdingandGitHub e5e3fac46e Merge pull request #130 from ErnoKilp/erno/fix_coverity_findings
Fix High and Medium Severity level coverity findings
2026-08-12 10:54:37 -04:00
Sheldon RobinsonandGitHub 8b3654d2e5 Merge branch 'mborgerding:master' into master 2026-07-28 11:58:00 -04:00
Erno Kilpelainen 5e5058275a Fix Medium Severity Coverity finding:
CWE-563 (Unused value)
(https://cwe.mitre.org/data/definitions/563.html)
2026-06-05 11:10:11 +00:00
Erno Kilpelainen 9711d6a7cb Fix Medium Severity Coverity finding:
CWE-252 (Ignoring number of bytes read)
(https://cwe.mitre.org/data/definitions/252.html)
2026-06-05 11:06:24 +00:00
Erno Kilpelainen 23fe68915b Fix Medium Severity Coverity finding:
CWE-252 (Ignoring number of bytes read
)
(https://cwe.mitre.org/data/definitions/252.html)
2026-06-05 11:04:13 +00:00
Erno Kilpelainen 6e2c3f160b Fix Medium Severity Coverity finding:
CWE-252 (Ignoring number of bytes read)
(https://cwe.mitre.org/data/definitions/252.html)
2026-06-05 11:02:03 +00:00
Erno Kilpelainen bce104a764 Fix Medium Severity Coverity finding:
CWE-252 (Ignoring number of bytes read)
(https://cwe.mitre.org/data/definitions/252.html)
2026-06-05 10:59:13 +00:00
Erno Kilpelainen ceb02a647d Fix Medium Severity Coverity finding:
CWE-369 (Division or modulo by float zero)
(https://cwe.mitre.org/data/definitions/369.html)
2026-06-05 10:56:41 +00:00
Erno Kilpelainen 280e28050a Fix Medium Severity Coverity finding:
CWE-369 (Division or modulo by float zero)
(https://cwe.mitre.org/data/definitions/369.html)
2026-06-05 10:53:56 +00:00
Erno Kilpelainen c11160e95f Fix Medium Coverity finding:
CWE-369 (Division or modulo by float zero)
(https://cwe.mitre.org/data/definitions/369.html)
2026-06-05 10:51:03 +00:00
Erno Kilpelainen 3aba02c166 Fix High severity coverity finding:
CWE-404 (Resource leak)
(https://cwe.mitre.org/data/definitions/404.html)
2026-06-05 10:48:07 +00:00
Erno Kilpelainen ab79e61148 Fix high severity Coverity finding:
CWE-119 (Out-of-bounds access)
(https://cwe.mitre.org/data/definitions/119.html)
2026-06-05 10:44:56 +00:00
Erno Kilpelainen 4c5d176b0d Fix High severity coverity finding:
CWE-78(OS Commadn injection
(https://cwe.mitre.org/data/definitions/78.html)
2026-06-05 10:40:11 +00:00
mborgerdingandGitHub 6398d8a1d0 Merge pull request #111 from HecaiYuan/master
loongarch: add loongarch simd opt
2026-05-11 20:03:41 -04:00
Sheldon RobinsonandGitHub d5f615afa8 Merge branch 'mborgerding:master' into master 2026-05-05 10:28:28 -04:00
mborgerdingandGitHub 6e9e673e42 Merge pull request #128 from vulgraph/backport/CVE-2026-41445-master
Backport CVE-2026-41445: kiss_fftndr_alloc overflow check
2026-04-22 10:31:51 -04:00
Mark Borgerdingandvulgraph aea492e132 kiss_fftndr_alloc: check for overflow (and _perhaps_ let combined dims > INT_MAX)
(cherry picked from commit 8a8e66e33d)
2026-04-22 19:27:18 +08:00
Martin RysandMartin 1e56ac8166 ci: Bump actions, fetch depth 1, remove unneeded deps 2026-03-07 17:10:08 +01:00
Sheldon RobinsonandGitHub c3ca17041b Add MSVC support for OpenMP in CMakeLists 2026-01-22 13:18:17 -05:00
niaandGitHub 39c9781711 Allow building on BSD/Solaris/etc with CMake (#64) 2025-11-28 20:58:39 +01:00
James Le CuirotandGitHub 1f5bbb1700 GNUInstallDirs is not supposed to be used conditionally (#91) 2025-11-28 20:41:52 +01:00
Martin RysandMartin 8e2620a597 Remove Python 2 mentions
Also fix up indents
2025-11-28 20:29:11 +01:00
Martin RysandMartin 45517b8a66 doit.c: Fix up indentation 2025-11-28 20:29:11 +01:00
Martin RysandMartin fe03ac54d6 ci: Add GitHub CI 2025-11-28 20:29:11 +01:00
Martin RysandMartin e47824731e Fix up README.md 2025-11-28 20:29:11 +01:00
Martin RysandMartin 3573584192 ci: Bump up versions and fix linting 2025-11-28 20:29:11 +01:00
dmoandGitHub 797c8ca9eb FIx python binary detection (#119) 2025-11-28 20:14:24 +01:00
Mark Borgerding 64fa219128 was unintentionally using abs(int) 2025-11-26 10:42:14 -05:00
Mark Borgerding 5899ee71c5 std::acosl was introduced in c++11, std::acos(long double) overload appears more robust 2025-11-26 10:41:21 -05:00
Mark Borgerding 1b08316582 check for overflow on 32 bit platform (closes #120) 2025-11-26 10:39:17 -05:00
Evan PorterandGitHub 7bce4153c6 README.md: Tweak wording (#100) 131.2.0 2025-09-12 07:55:11 +02:00
MartinandGitHub 6c56a03a6b tests/CMakeLists.txt: Fix CMP0148 (#108)
See `cmake --help-policy CMP0148`
2025-09-12 07:36:15 +02:00
Martin 6f8bc97c82 README.md: Correctly capitalize simd option 2025-09-12 07:17:48 +02:00
Martin 203dbd4eff Makefile: Do not fail creating pkgconfig directory if it already exists 2025-09-12 07:17:33 +02:00
c519408e76 kissfft-config.cmake: Bump minimum version to 3.10
---------

Co-authored-by: Martin <[email protected]>
2025-09-12 07:15:57 +02:00
MartinandGitHub b60dc8b9c7 CMakeLists.txt: Bump minimum version to 3.10 2025-09-12 07:13:27 +02:00