default_chan_name = DEFAULT_JUL_CHANNEL_NAME;
}
- ret = cmd_enable_event(session, &tmp_dom, (char *) default_chan_name,
- &uevent, filter_expression, filter, NULL, wpipe);
- /* We have passed ownership */
- filter_expression = NULL;
- filter = NULL;
+ {
+ struct lttng_filter_bytecode *filter_copy = NULL;
+
+ if (filter) {
+ filter_copy = zmalloc(
+ sizeof(struct lttng_filter_bytecode)
+ + filter->len);
+ if (!filter_copy) {
+ goto error;
+ }
+
+ memcpy(filter_copy, filter,
+ sizeof(struct lttng_filter_bytecode)
+ + filter->len);
+ }
+
+ ret = cmd_enable_event(session, &tmp_dom,
+ (char *) default_chan_name,
+ &uevent, filter_expression, filter_copy,
+ NULL, wpipe);
+ /* We have passed ownership */
+ filter_expression = NULL;
+ }
+
if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) {
goto error;
}
/* The wild card * means that everything should be enabled. */
if (strncmp(event->name, "*", 1) == 0 && strlen(event->name) == 1) {
ret = event_agent_enable_all(usess, agt, event, filter);
+ filter = NULL;
} else {
ret = event_agent_enable(usess, agt, event, filter);
+ filter = NULL;
}
if (ret != LTTNG_OK) {
goto error;