X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Flttng-ctl.c;h=96351bdcf25b81318e8af78bcd1a5fc742a21a22;hp=6238d9a00749865e23e390c2ac87b9e8799a09af;hb=52df24019c3998b87870fb8371fa20fb33449a0d;hpb=b6bbed5f19b7d7102a1461820adc7f54ca3857ee diff --git a/src/lib/lttng-ctl/lttng-ctl.c b/src/lib/lttng-ctl/lttng-ctl.c index 6238d9a00..96351bdcf 100644 --- a/src/lib/lttng-ctl/lttng-ctl.c +++ b/src/lib/lttng-ctl/lttng-ctl.c @@ -841,8 +841,20 @@ int lttng_enable_event_with_filter(struct lttng_handle *handle, FILE *fmem; int ret = 0; - /* Safety check. */ - if (handle == NULL || !filter_expression) { + if (!filter_expression) { + /* + * Fall back to normal event enabling if no filter + * specified. + */ + return lttng_enable_event(handle, event, channel_name); + } + + /* + * Empty filter string will always be rejected by the parser + * anyway, so treat this corner-case early to eliminate + * lttng_fmemopen error for 0-byte allocation. + */ + if (handle == NULL || filter_expression[0] == '\0') { return -LTTNG_ERR_INVALID; }