aboutsummaryrefslogtreecommitdiff
path: root/src/init.c
diff options
context:
space:
mode:
authorJamie Bullock <jamie@jamiebullock.com>2014-03-07 21:42:46 +0000
committerJamie Bullock <jamie@jamiebullock.com>2014-03-07 21:42:46 +0000
commit43482939ccd1a73a359191524a851dbab14743d0 (patch)
tree0abb5e0cbec8eafc5fe8a98567f7279863fcd8b8 /src/init.c
parentba43f60b2d0445b2739e54beb0c1813f3ac00345 (diff)
downloadLibXtract-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.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/init.c b/src/init.c
index 10c5535..b858a19 100644
--- a/src/init.c
+++ b/src/init.c
@@ -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;