Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-04-12 22:23:23 +0400
committerFelix Fietkau <nbd@openwrt.org>2014-04-12 22:23:23 +0400
commit31b2d244fdd9e232b9686c1ffd833518b712d884 (patch)
tree3ec8fa4e068299548e506fe13e524fb123bf830d /blobmsg_json.c
parentc725f9f7a551bf31fd315d66c2a8a7fb8892b911 (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.c4
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;