From 30c7f4f49e603a2f1188ec16ecdda898a013a7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20V=C3=B6r=C3=B6s?= Date: Sun, 28 Jan 2024 12:41:00 +0100 Subject: [PATCH] fix segmentation fault on temporary buffer --- code/utils/utils.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/utils/utils.c b/code/utils/utils.c index 614f4f7e..8477f5de 100644 --- a/code/utils/utils.c +++ b/code/utils/utils.c @@ -367,10 +367,13 @@ mp_obj_t utils_spectrogram(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw spectrum += spectrum_sz; } - // FIXME: - // if(scratchpad_object == mp_const_none) { - // m_del(mp_float_t, tmp, 2 * len); - // } + if(scratchpad_object == mp_const_none) { + tmp -= len; + #if ULAB_FFT_IS_NUMPY_COMPATIBLE + tmp -= len; + #endif + m_del(mp_float_t, tmp, 2 * len); + } return MP_OBJ_FROM_PTR(out); }