Signed-off-by: Mathieu Desnoyers <[email protected]>
---
 src/bin/lttng-sessiond/main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c
index 9542e65..50da40c 100644
--- a/src/bin/lttng-sessiond/main.c
+++ b/src/bin/lttng-sessiond/main.c
@@ -3217,12 +3217,14 @@ skip_domain:
 
                        if (bytecode_len > LTTNG_FILTER_MAX_LEN) {
                                ret = LTTNG_ERR_FILTER_INVAL;
+                               free(filter_expression);
                                free(exclusion);
                                goto error;
                        }
 
                        bytecode = zmalloc(bytecode_len);
                        if (!bytecode) {
+                               free(filter_expression);
                                free(exclusion);
                                ret = LTTNG_ERR_FILTER_NOMEM;
                                goto error;
@@ -3234,6 +3236,7 @@ skip_domain:
                        if (ret <= 0) {
                                DBG("Nothing recv() from client car len data... 
continuing");
                                *sock_error = 1;
+                               free(filter_expression);
                                free(bytecode);
                                free(exclusion);
                                ret = LTTNG_ERR_FILTER_INVAL;
@@ -3241,6 +3244,7 @@ skip_domain:
                        }
 
                        if ((bytecode->len + sizeof(*bytecode)) != 
bytecode_len) {
+                               free(filter_expression);
                                free(bytecode);
                                free(exclusion);
                                ret = LTTNG_ERR_FILTER_INVAL;
@@ -3253,6 +3257,12 @@ skip_domain:
                                &cmd_ctx->lsm->u.enable.event,
                                filter_expression, bytecode, exclusion,
                                kernel_poll_pipe[1]);
+               if (ret != LTTNG_OK) {
+                       /* On error, we still have ownership. */
+                       free(filter_expression);
+                       free(bytecode);
+                       free(exclusion);
+               }
                break;
        }
        case LTTNG_LIST_TRACEPOINTS:
-- 
2.1.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to