From 751e541776dca79e00587b6367833bb86ef2c8fb Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Sun, 12 Nov 2017 17:20:13 +0800 Subject: [PATCH] Fix Bug: Memory leak Signed-off-by: Jianhui Zhao --- src/uhttp_buf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/uhttp_buf.c b/src/uhttp_buf.c index 00fc82d..5c5af83 100755 --- a/src/uhttp_buf.c +++ b/src/uhttp_buf.c @@ -5,7 +5,11 @@ int uh_buf_init(struct uh_buf *buf, size_t initial_size) { buf->len = buf->size = 0; - buf->base = NULL; + + if (buf->base) { + free(buf->base); + buf->base = NULL; + } if (initial_size > 0) { buf->base = malloc(initial_size);