From: Juho Vähä-Herttua Date: Wed, 21 Mar 2012 12:01:35 +0000 (+0200) Subject: Fix a memory leak in the ALAC decoder. X-Git-Tag: upstream/0.9.0~4^2~88 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=982a0c2652606004b80c1a79827683359f5676d3;p=deb_shairplay.git Fix a memory leak in the ALAC decoder. --- diff --git a/src/lib/alac/alac.c b/src/lib/alac/alac.c index 9d575ae..195e66a 100644 --- a/src/lib/alac/alac.c +++ b/src/lib/alac/alac.c @@ -111,6 +111,24 @@ static void allocate_buffers(alac_file *alac) alac->uncompressed_bytes_buffer_b = malloc(alac->setinfo_max_samples_per_frame * 4); } +static void deallocate_buffers(alac_file *alac) +{ + free(alac->predicterror_buffer_a); + free(alac->predicterror_buffer_b); + alac->predicterror_buffer_a = NULL; + alac->predicterror_buffer_b = NULL; + + free(alac->outputsamples_buffer_a); + free(alac->outputsamples_buffer_b); + alac->outputsamples_buffer_a = NULL; + alac->outputsamples_buffer_b = NULL; + + free(alac->uncompressed_bytes_buffer_a); + free(alac->uncompressed_bytes_buffer_b); + alac->uncompressed_bytes_buffer_a = NULL; + alac->uncompressed_bytes_buffer_b = NULL; +} + void alac_set_info(alac_file *alac, char *inputbuffer) { char *ptr = inputbuffer; @@ -1170,3 +1188,9 @@ alac_file *create_alac(int samplesize, int numchannels) return newfile; } +void destroy_alac(alac_file *alac) +{ + if (!alac) return; + deallocate_buffers(alac); + free(alac); +} diff --git a/src/lib/alac/alac.h b/src/lib/alac/alac.h index 23dbc52..e5bf814 100644 --- a/src/lib/alac/alac.h +++ b/src/lib/alac/alac.h @@ -8,6 +8,7 @@ void decode_frame(alac_file *alac, unsigned char *inbuffer, void *outbuffer, int *outputsize); void alac_set_info(alac_file *alac, char *inputbuffer); +void destroy_alac(alac_file *alac); #endif /* __ALAC__DECOMP_H */ diff --git a/src/lib/raop_buffer.c b/src/lib/raop_buffer.c index b9b52af..7869d1d 100644 --- a/src/lib/raop_buffer.c +++ b/src/lib/raop_buffer.c @@ -211,8 +211,8 @@ void raop_buffer_destroy(raop_buffer_t *raop_buffer) { if (raop_buffer) { + destroy_alac(raop_buffer->alac); free(raop_buffer->buffer); - free(raop_buffer->alac); free(raop_buffer); } }