Fix: lttng-add-context: leak of application context parameters
[lttng-tools.git] / src / bin / lttng / commands / add_context.c
index b33eb1d14ef22545b73baeceed6d6a19424b9e8c..16389e11398573d71f7c4e81eb61dde06688d4d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
  * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * SPDX-License-Identifier: GPL-2.0-only
@@ -19,6 +19,7 @@
 
 #include <urcu/list.h>
 
+#include <lttng/domain-internal.h>
 #include <common/mi-lttng.h>
 
 #include "../command.h"
@@ -810,11 +811,13 @@ static int add_context(char *session_name)
                } else {
                        if (opt_channel_name) {
                                MSG("%s context %s added to channel %s",
-                                               get_domain_str(dom.type), type->opt->symbol,
+                                               lttng_domain_type_str(dom.type),
+                                               type->opt->symbol,
                                                opt_channel_name);
                        } else {
                                MSG("%s context %s added to all channels",
-                                               get_domain_str(dom.type), type->opt->symbol);
+                                               lttng_domain_type_str(dom.type),
+                                               type->opt->symbol);
                        }
                        success = 1;
                }
@@ -868,6 +871,10 @@ void destroy_ctx_type(struct ctx_type *type)
        }
        if (type->opt) {
                free(type->opt->symbol);
+               if (type->opt->ctx_type == CONTEXT_APP_CONTEXT) {
+                       free(type->opt->u.app_ctx.ctx_name);
+                       free(type->opt->u.app_ctx.provider_name);
+               }
        }
        free(type->opt);
        free(type);
This page took 0.024315 seconds and 4 git commands to generate.