filter-chain: clean up on errors

This commit is contained in:
Wim Taymans 2021-11-17 12:49:00 +01:00
parent 1b88e0023b
commit cf66400035

View file

@ -181,14 +181,14 @@ static struct convolver1 *convolver1_new(int block, const float *ir, int irlen)
conv->fft = fft_new(conv->segSize); conv->fft = fft_new(conv->segSize);
if (conv->fft == NULL) if (conv->fft == NULL)
return NULL; goto error;
conv->ifft = ifft_new(conv->segSize); conv->ifft = ifft_new(conv->segSize);
if (conv->ifft == NULL) if (conv->ifft == NULL)
return NULL; goto error;
conv->fft_buffer = fft_alloc(conv->segSize); conv->fft_buffer = fft_alloc(conv->segSize);
if (conv->fft_buffer == NULL) if (conv->fft_buffer == NULL)
return NULL; goto error;
conv->segments = calloc(sizeof(struct fft_cpx), conv->segCount); conv->segments = calloc(sizeof(struct fft_cpx), conv->segCount);
conv->segmentsIr = calloc(sizeof(struct fft_cpx), conv->segCount); conv->segmentsIr = calloc(sizeof(struct fft_cpx), conv->segCount);
@ -214,6 +214,15 @@ static struct convolver1 *convolver1_new(int block, const float *ir, int irlen)
convolver1_reset(conv); convolver1_reset(conv);
return conv; return conv;
error:
if (conv->fft)
fft_destroy(conv->fft);
if (conv->ifft)
fft_destroy(conv->ifft);
if (conv->fft_buffer)
fft_free(conv->fft_buffer);
free(conv);
return NULL;
} }
static void convolver1_free(struct convolver1 *conv) static void convolver1_free(struct convolver1 *conv)