From 13d0eca71dcd4ff50aca91d68f6c2cf7510d791b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20Wallm=C3=A9nius?= Date: Thu, 12 Aug 2010 07:50:29 +0000 Subject: libtremor: fix possible memoryleak when playing several ogg vorbis files in sequence, hopefully fixes FS#11533 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27776 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/libtremor/block.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/codecs/libtremor/block.c b/apps/codecs/libtremor/block.c index b4ca8f3..abf2166 100644 --- a/apps/codecs/libtremor/block.c +++ b/apps/codecs/libtremor/block.c @@ -40,6 +40,8 @@ static int ilog(unsigned int v){ static ogg_int32_t* _pcmp [CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmbp[CHANNELS] IBSS_ATTR; static ogg_int32_t* _pcmret[CHANNELS] IBSS_ATTR; +/* save original pointer returned by malloc so we can free it easily */ +static ogg_int32_t* _first_pcm = NULL; /* pcm accumulator examples (not exhaustive): @@ -165,10 +167,11 @@ static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ /* allocate IRAM buffer for the PCM data generated by synthesis */ iram_malloc_init(); - v->first_pcm=(ogg_int32_t *)iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + v->first_pcm = iram_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); /* when can't allocate IRAM buffer, allocate normal RAM buffer */ if(v->first_pcm == NULL){ - v->first_pcm=(ogg_int32_t *)_ogg_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + _first_pcm = _ogg_malloc(vi->channels*ci->blocksizes[1]*sizeof(ogg_int32_t)); + v->first_pcm= _first_pcm; } v->centerW=0; @@ -287,6 +290,9 @@ void vorbis_dsp_clear(vorbis_dsp_state *v){ codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); private_state *b=(private_state *)v->backend_state; + if(_first_pcm != NULL) + _ogg_free(_first_pcm); + if(NULL == v->iram_double_pcm && vi != NULL) { /* pcm buffer came from oggmalloc rather than iram */ -- cgit v1.1