diff options
author | Felix Fietkau <nbd@openwrt.org> | 2014-04-12 22:23:23 +0400 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-04-12 22:23:23 +0400 |
commit | 31b2d244fdd9e232b9686c1ffd833518b712d884 (patch) | |
tree | 3ec8fa4e068299548e506fe13e524fb123bf830d /blobmsg_json.c | |
parent | c725f9f7a551bf31fd315d66c2a8a7fb8892b911 (diff) |
blobmsg_json: fix a memleak on error
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'blobmsg_json.c')
-rw-r--r-- | blobmsg_json.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; |