blobmsg_json: fix a memleak on error

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
Felix Fietkau 2014-04-12 20:23:23 +02:00
parent c725f9f7a5
commit 31b2d244fd

View file

@ -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;