return false;
in->command = cur;
- in->trigger = tb[INSTANCE_ATTR_TRIGGER];
- if (in->trigger)
+ if (tb[INSTANCE_ATTR_TRIGGER]) {
+ in->trigger = malloc(blob_len(tb[INSTANCE_ATTR_TRIGGER]));
+ if (!in->trigger)
+ return -1;
+ memcpy(in->trigger, tb[INSTANCE_ATTR_TRIGGER], blob_len(tb[INSTANCE_ATTR_TRIGGER]));
trigger_add(in->trigger, in);
+ }
if ((cur = tb[INSTANCE_ATTR_NICE])) {
in->nice = (int8_t) blobmsg_get_u32(cur);
uloop_process_delete(&in->proc);
uloop_timeout_cancel(&in->timeout);
trigger_del(in);
+ free(in->trigger);
instance_config_cleanup(in);
free(in->config);
free(in);
struct blob_attr *cur;
int rem;
- if (s->trigger)
+ if (s->trigger) {
trigger_del(s);
+ free(s->trigger);
+ s->trigger = NULL;
+ }
if (tb[SERVICE_SET_TRIGGER] && blobmsg_data_len(tb[SERVICE_SET_TRIGGER])) {
- s->trigger = tb[SERVICE_SET_TRIGGER];
+ s->trigger = malloc(blob_len(tb[SERVICE_SET_TRIGGER]));
+ if (!s->trigger)
+ return -1;
+ memcpy(s->trigger, tb[SERVICE_SET_TRIGGER], blob_len(tb[SERVICE_SET_TRIGGER]));
trigger_add(s->trigger, s);
}
vlist_flush_all(&s->instances);
avl_delete(&services, &s->avl);
trigger_del(s);
+ s->trigger = NULL;
+ free(s->trigger);
free(s->config);
free(s);
}