From 31b2d244fdd9e232b9686c1ffd833518b712d884 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 12 Apr 2014 20:23:23 +0200 Subject: [PATCH] blobmsg_json: fix a memleak on error Signed-off-by: Felix Fietkau --- blobmsg_json.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/blobmsg_json.c b/blobmsg_json.c index c84fd93..3b32b93 100644 --- a/blobmsg_json.c +++ b/blobmsg_json.c @@ -304,8 +304,10 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso else blobmsg_format_element(&s, attr, false, false); - if (!s.len) + if (!s.len) { + free(s.buf); return NULL; + } s.buf = realloc(s.buf, s.pos + 1); s.buf[s.pos] = 0; -- 2.30.2