mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
bbfdmd: Fix memory leaks
This commit is contained in:
parent
e1262f19a3
commit
115d945afd
2 changed files with 9 additions and 2 deletions
|
|
@ -622,6 +622,7 @@ static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *o
|
|||
{
|
||||
struct blob_attr *tb[__DM_OPERATE_MAX] = {NULL};
|
||||
char path[PATH_MAX] = {0};
|
||||
char *str = NULL;
|
||||
bbfdm_data_t data;
|
||||
|
||||
memset(&data, 0, sizeof(bbfdm_data_t));
|
||||
|
|
@ -641,8 +642,10 @@ static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *o
|
|||
data.bbf_ctx.in_param = path;
|
||||
data.bbf_ctx.linker = tb[DM_OPERATE_COMMAND_KEY] ? blobmsg_get_string(tb[DM_OPERATE_COMMAND_KEY]) : "";
|
||||
|
||||
str = blobmsg_format_json(tb[DM_OPERATE_INPUT], true);
|
||||
|
||||
if (tb[DM_OPERATE_INPUT])
|
||||
data.bbf_ctx.in_value = blobmsg_format_json(tb[DM_OPERATE_INPUT], true);
|
||||
data.bbf_ctx.in_value = str;
|
||||
|
||||
fill_optional_data(&data, tb[DM_OPERATE_OPTIONAL]);
|
||||
|
||||
|
|
@ -654,6 +657,7 @@ static int bbfdm_operate_handler(struct ubus_context *ctx, struct ubus_object *o
|
|||
bbfdm_start_deferred(&data, bbfdm_operate_cmd_async);
|
||||
}
|
||||
|
||||
FREE(str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,11 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand
|
|||
if (dm_path == NULL)
|
||||
return;
|
||||
|
||||
char *str = blobmsg_format_json(msg, true);
|
||||
|
||||
struct dmctx bbf_ctx = {
|
||||
.in_param = dm_path,
|
||||
.in_value = blobmsg_format_json(msg, true),
|
||||
.in_value = str,
|
||||
.nextlevel = false,
|
||||
.iscommand = false,
|
||||
.isevent = true,
|
||||
|
|
@ -96,6 +98,7 @@ static void bbfdm_event_handler(struct ubus_context *ctx, struct ubus_event_hand
|
|||
|
||||
end:
|
||||
bbf_cleanup(&bbf_ctx);
|
||||
FREE(str);
|
||||
}
|
||||
|
||||
static void add_ubus_event_handler(struct ubus_event_handler *ev, const char *ev_name, const char *dm_path, struct list_head *ev_list)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue