Fix: lttng: enable-channel: leak of popt arguments
[lttng-tools.git] / src / bin / lttng / commands / enable_channels.cpp
index d62aa8656c51a84b395bda2f461e3b98b632a8ea..a7fffbff1b155409f1f613bd2e29bdf47cda29fd 100644 (file)
 #include <inttypes.h>
 #include <ctype.h>
 
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/utils.h>
-#include <common/mi-lttng.h>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/utils.hpp>
+#include <common/mi-lttng.hpp>
 
-#include <lttng/domain-internal.h>
+#include <lttng/domain-internal.hpp>
 
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
 
 
 static struct lttng_channel chan_opts;
@@ -644,6 +644,11 @@ int cmd_enable_channels(int argc, const char **argv)
                        ret = CMD_UNDEFINED;
                        goto end;
                }
+
+               if (opt_arg) {
+                       free(opt_arg);
+                       opt_arg = nullptr;
+               }
        }
 
        ret = print_missing_or_multiple_domains(
@@ -755,5 +760,6 @@ end:
        /* Overwrite ret if an error occurred when enable_channel */
        ret = command_ret ? command_ret : ret;
        poptFreeContext(pc);
+       free(opt_arg);
        return ret;
 }
This page took 0.022893 seconds and 4 git commands to generate.