blobmsg_json: fix a memleak on error
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
c725f9f7a5
commit
31b2d244fd
1 changed files with 3 additions and 1 deletions
|
@ -304,8 +304,10 @@ char *blobmsg_format_json_with_cb(struct blob_attr *attr, bool list, blobmsg_jso
|
||||||
else
|
else
|
||||||
blobmsg_format_element(&s, attr, false, false);
|
blobmsg_format_element(&s, attr, false, false);
|
||||||
|
|
||||||
if (!s.len)
|
if (!s.len) {
|
||||||
|
free(s.buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
s.buf = realloc(s.buf, s.pos + 1);
|
s.buf = realloc(s.buf, s.pos + 1);
|
||||||
s.buf[s.pos] = 0;
|
s.buf[s.pos] = 0;
|
||||||
|
|
Loading…
Reference in a new issue