summaryrefslogtreecommitdiffstats
path: root/plug
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2014-05-25 20:48:09 +0200
committerFelix Fietkau <nbd@openwrt.org>2014-05-25 20:48:09 +0200
commit695c2196d7fcdf8ac7b63e755e108755ce85ce3b (patch)
tree18ce5e8586a3012828a4e87093f3be0bb4f277fd /plug
parent8f4162f82af7186a49bc697a43b549b7e3146385 (diff)
downloadunitd-695c2196d7fcdf8ac7b63e755e108755ce85ce3b.tar
unitd-695c2196d7fcdf8ac7b63e755e108755ce85ce3b.zip
hotplug: fix memleak in debug codepath
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'plug')
-rw-r--r--plug/hotplug.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/plug/hotplug.c b/plug/hotplug.c
index ca1e823..07abaf8 100644
--- a/plug/hotplug.c
+++ b/plug/hotplug.c
@@ -399,6 +399,18 @@ static struct json_script_ctx jctx = {
.handle_file = rule_handle_file,
};
+static void hotplug_handler_debug(struct blob_attr *data)
+{
+ char *str;
+
+ if (debug < 3)
+ return;
+
+ str = blobmsg_format_json(data, true);
+ DEBUG(3, "%s\n", str);
+ free(str);
+}
+
static void hotplug_handler(struct uloop_fd *u, unsigned int ev)
{
int i = 0;
@@ -421,7 +433,7 @@ static void hotplug_handler(struct uloop_fd *u, unsigned int ev)
i += l;
}
blobmsg_close_table(&b, index);
- DEBUG(3, "%s\n", blobmsg_format_json(b.head, true));
+ hotplug_handler_debug(b.head);
json_script_run(&jctx, rule_file, blob_data(b.head));
}