From: Andrei Emeltchenko <[email protected]>
free allocated memory before exit
---
src/shared/ringbuf.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/shared/ringbuf.c b/src/shared/ringbuf.c
index 3e5c7d3..d59dc5c 100644
--- a/src/shared/ringbuf.c
+++ b/src/shared/ringbuf.c
@@ -228,9 +228,14 @@ int ringbuf_vprintf(struct ringbuf *ringbuf, const char *format, va_list ap)
return -1;
len = vasprintf(&str, format, ap);
- if (len < 0 || (size_t) len > avail)
+ if (len < 0)
return -1;
+ if ((size_t) len > avail) {
+ free(str);
+ return -1;
+ }
+
/* Determine possible length of string before wrapping */
offset = ringbuf->in & (ringbuf->size - 1);
end = MIN((size_t) len, ringbuf->size - offset);
--
1.8.3.2
Hi Andrei,
On Mon, Jan 27, 2014, Andrei Emeltchenko wrote:
> free allocated memory before exit
> ---
> src/shared/ringbuf.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Applied. Thanks.
Johan