Fix: lttng: add-trigger: leak of parser context on capture
[lttng-tools.git] / src / bin / lttng / commands / add_trigger.cpp
index 82b2c016215ce714e789ca3dbbf5abd04249eb24..8619a822161eda44fbe2f61aceb7dedae8c07781 100644 (file)
 #include <string.h>
 #include <stdarg.h>
 
-#include "../command.h"
-#include "../loglevel.h"
-#include "../uprobe.h"
+#include "../command.hpp"
+#include "../loglevel.hpp"
+#include "../uprobe.hpp"
 
 #include "common/argpar/argpar.h"
-#include "common/argpar-utils/argpar-utils.h"
-#include "common/dynamic-array.h"
-#include "common/mi-lttng.h"
-#include "common/string-utils/string-utils.h"
-#include "common/utils.h"
-#include <lttng/domain-internal.h>
+#include "common/argpar-utils/argpar-utils.hpp"
+#include "common/dynamic-array.hpp"
+#include "common/mi-lttng.hpp"
+#include "common/string-utils/string-utils.hpp"
+#include "common/utils.hpp"
+#include <lttng/domain-internal.hpp>
 /* For lttng_event_rule_type_str(). */
-#include <lttng/event-rule/event-rule-internal.h>
+#include <lttng/event-rule/event-rule-internal.hpp>
 #include <lttng/lttng.h>
-#include "common/filter/filter-ast.h"
-#include "common/filter/filter-ir.h"
-#include "common/dynamic-array.h"
+#include "common/filter/filter-ast.hpp"
+#include "common/filter/filter-ir.hpp"
+#include "common/dynamic-array.hpp"
 
 #if (LTTNG_SYMBOL_NAME_LEN == 256)
 #define LTTNG_SYMBOL_NAME_LEN_SCANF_IS_A_BROKEN_API "255"
@@ -640,6 +640,7 @@ void destroy_event_expr(void *ptr)
        lttng_event_expr_destroy((lttng_event_expr *) ptr);
 }
 
+namespace {
 struct parse_event_rule_res {
        /* Owned by this. */
        struct lttng_event_rule *er;
@@ -647,6 +648,7 @@ struct parse_event_rule_res {
        /* Array of `struct lttng_event_expr *` */
        struct lttng_dynamic_pointer_array capture_descriptors;
 };
+} /* namespace */
 
 static
 struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv,
@@ -787,6 +789,8 @@ struct parse_event_rule_res parse_event_rule(int *argc, const char ***argv,
 
                                event_expr = ir_op_root_to_event_expr(
                                                parser_ctx->ir_root, arg);
+                               filter_parser_ctx_free(parser_ctx);
+                               parser_ctx = nullptr;
                                if (!event_expr) {
                                        /*
                                         * ir_op_root_to_event_expr has printed
@@ -1404,11 +1408,13 @@ end:
        return c;
 }
 
+namespace {
 struct condition_descr {
        const char *name;
        struct lttng_condition *(*handler) (int *argc, const char ***argv,
                int argc_offset);
 };
+} /* namespace */
 
 static const
 struct condition_descr condition_descrs[] = {
@@ -2099,11 +2105,13 @@ end:
        return action;
 }
 
+namespace {
 struct action_descr {
        const char *name;
        struct lttng_action *(*handler) (int *argc, const char ***argv,
                int argc_offset);
 };
+} /* namespace */
 
 static const
 struct action_descr action_descrs[] = {
This page took 0.024117 seconds and 4 git commands to generate.