fix memory leak

This commit is contained in:
Clemens Ladisch 2004-07-20 15:36:08 +00:00
parent f3fff3e0ef
commit 45814d5ec5

View file

@ -250,6 +250,8 @@ static int snd_output_buffer_need(snd_output_t *output, size_t size)
snd_output_buffer_t *buffer = output->private_data;
size_t _free = buffer->alloc - buffer->size;
size_t alloc;
unsigned char *buf;
if (_free >= size)
return _free;
if (buffer->alloc == 0)
@ -258,9 +260,10 @@ static int snd_output_buffer_need(snd_output_t *output, size_t size)
alloc = buffer->alloc;
while (alloc < size)
alloc *= 2;
buffer->buf = realloc(buffer->buf, alloc);
if (!buffer->buf)
buf = realloc(buffer->buf, alloc);
if (!buf)
return -ENOMEM;
buffer->buf = buf;
buffer->alloc = alloc;
return buffer->alloc - buffer->size;
}