From: Felix Fietkau Date: Thu, 4 Feb 2016 19:37:07 +0000 (+0100) Subject: trigger: fix memory leak in script calls X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e08f52e4f5fb1f20c09e7c69a616b76dc4710d6b;p=project%2Fprocd.git trigger: fix memory leak in script calls Signed-off-by: Felix Fietkau --- 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); } } }