diff options
author | Jamie Bullock <jamie@jamiebullock.com> | 2014-03-07 21:42:46 +0000 |
---|---|---|
committer | Jamie Bullock <jamie@jamiebullock.com> | 2014-03-07 21:42:46 +0000 |
commit | 43482939ccd1a73a359191524a851dbab14743d0 (patch) | |
tree | 0abb5e0cbec8eafc5fe8a98567f7279863fcd8b8 /src/init.c | |
parent | ba43f60b2d0445b2739e54beb0c1813f3ac00345 (diff) | |
download | LibXtract-43482939ccd1a73a359191524a851dbab14743d0.tar.gz LibXtract-43482939ccd1a73a359191524a851dbab14743d0.tar.bz2 LibXtract-43482939ccd1a73a359191524a851dbab14743d0.zip |
Fix potential memory leak
Diffstat (limited to 'src/init.c')
-rw-r--r-- | src/init.c | 29 |
1 files changed, 26 insertions, 3 deletions
@@ -257,13 +257,36 @@ int xtract_init_mfcc(int N, double nyquist, int style, double freq_min, double f mel_peak = (double *)malloc((freq_bands + 2) * sizeof(double)); /* +2 for zeros at start and end */ + + if (mel_peak == NULL) + { + perror("error"); + return XTRACT_MALLOC_FAILED; + } + lin_peak = (double *)malloc((freq_bands + 2) * sizeof(double)); + + if (lin_peak == NULL) + { + perror("error"); + return XTRACT_MALLOC_FAILED; + } + fft_peak = (int *)malloc((freq_bands + 2) * sizeof(int)); + + if (fft_peak == NULL) + { + perror("error"); + return XTRACT_MALLOC_FAILED; + } + height_norm = (double *)malloc(freq_bands * sizeof(double)); - - if(mel_peak == NULL || height_norm == NULL || - lin_peak == NULL || fft_peak == NULL) + + if (height_norm == NULL) + { + perror("error"); return XTRACT_MALLOC_FAILED; + } M = N >> 1; |