From d8ccb037a0b9eeb643a8aed08279f052d20ef4a4 Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Tue, 27 Nov 2018 23:21:25 +0100 Subject: [PATCH] Fix memset size In the call to memset(), the size of the pointer to mag2buf was erroneously used instead of size of what mag2buf pointed to (float). This leads to problems on systems where the size of the pointer is different from the size of floats. Instead of just fixing the size, use calloc() instead of malloc() to directly set the memory to 0. --- tools/psdpng.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/psdpng.c b/tools/psdpng.c index 15e640b..91c02dd 100644 --- a/tools/psdpng.c +++ b/tools/psdpng.c @@ -129,9 +129,7 @@ void transform_signal(void) CHECKNULL( inbuf=(short*)malloc(sizeof(short)*2*nfft ) ); CHECKNULL( tbuf=(kiss_fft_scalar*)malloc(sizeof(kiss_fft_scalar)*nfft ) ); CHECKNULL( fbuf=(kiss_fft_cpx*)malloc(sizeof(kiss_fft_cpx)*nfreqs ) ); - CHECKNULL( mag2buf=(float*)malloc(sizeof(float)*nfreqs ) ); - - memset(mag2buf,0,sizeof(mag2buf)*nfreqs); + CHECKNULL( mag2buf=(float*)calloc(nfreqs,sizeof(float) ) ); while (1) { if (stereo) {