From e08f52e4f5fb1f20c09e7c69a616b76dc4710d6b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 4 Feb 2016 20:37:07 +0100 Subject: [PATCH] trigger: fix memory leak in script calls Signed-off-by: Felix Fietkau --- service/trigger.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/service/trigger.c b/service/trigger.c index 97a06bb..fb249b6 100644 --- a/service/trigger.c +++ b/service/trigger.c @@ -77,6 +77,9 @@ rule_load_script(struct json_script_ctx *ctx, const char *name) { struct trigger *t = container_of(ctx, struct trigger, jctx); + if (strcmp(name, t->type) != 0) + return NULL; + return json_script_file_from_blobmsg(t->type, t->rule, blob_pad_len(t->rule)); } @@ -225,7 +228,7 @@ static void trigger_delay_cb(struct uloop_timeout *tout) { struct trigger *t = container_of(tout, struct trigger, delay); - json_script_run(&t->jctx, "foo", t->data); + json_script_run(&t->jctx, t->type, t->data); free(t->data); t->data = NULL; } @@ -344,7 +347,7 @@ void trigger_event(const char *type, struct blob_attr *data) t->data = blob_memdup(data); uloop_timeout_set(&t->delay, t->timeout); } else { - json_script_run(&t->jctx, "foo", data); + json_script_run(&t->jctx, t->type, data); } } } -- 2.11.0