Commit 6f256f60 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Fix a memory leak in the FLAC decoder.

resize_buffer() would only free the channel buffers when the
 channel count changed, not when the size of the buffer changed,
 even though it allocated new buffers in both cases.

svn path=/trunk/vorbis-tools/; revision=18382
parent 260d76b6
......@@ -341,17 +341,15 @@ void resize_buffer(flacfile *flac, int newchannels, int newsamples)
return;
}
/* Deallocate all of the sample vectors */
for (i = 0; i < flac->channels; i++)
free(flac->buf[i]);
/* Not the most efficient approach, but it is easy to follow */
if(newchannels != flac->channels)
{
/* Deallocate all of the sample vectors */
for (i = 0; i < flac->channels; i++)
free(flac->buf[i]);
flac->buf = realloc(flac->buf, sizeof(float*) * newchannels);
flac->channels = newchannels;
}
for (i = 0; i < newchannels; i++)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment