Skip to content

Commit f205184

Browse files
committed
Fix Coverity OVERRUN false positive in _allocate_result
Declare f_ndim as a C int so that f_ndim * sizeof(npy_intp) is computed as a plain C multiplication instead of being routed through a Python object. The untyped variable caused Cython to generate a __Pyx_PyLong_As_size_t conversion whose (size_t)-1 error sentinel led Coverity to report an out-of-bounds access (OVERRUN, CID 652776/652762) on the PyMem_Malloc/memcpy of f_shape. This mirrors b_ndim in _pad_array, which is already typed and was never flagged.
1 parent 25ceb1e commit f205184

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
### Changed
1212

1313
### Fixed
14+
* Declared `f_ndim` as a C `int` in `_allocate_result` so the buffer size is computed in C rather than through a Python object, resolving a Coverity out-of-bounds (OVERRUN) false positive [gh-364](https://github.com/IntelPython/mkl_fft/pull/364)
1415

1516
## [2.3.2] - 2026-08-04
1617

mkl_fft/_pydfti.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ cdef cnp.ndarray _allocate_result(
302302
cdef cnp.npy_intp *f_shape
303303
cdef cnp.ndarray f_arr "ff_arrayObject"
304304
cdef int x_arr_is_fortran
305+
cdef int f_ndim
305306

306307
f_ndim = cnp.PyArray_NDIM(x_arr)
307308

0 commit comments

Comments
 (0)