From 45814d5ec5ff1760ff5052661503545f94f026ba Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 20 Jul 2004 15:36:08 +0000 Subject: [PATCH] fix memory leak --- src/output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/output.c b/src/output.c index 2fbabed2..071113bd 100644 --- a/src/output.c +++ b/src/output.c @@ -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; } -- 2.47.1