Tests: fix: lttng-create: leaked command parameter
[lttng-tools.git] / src / bin / lttng / commands / create.cpp
index b46893d5eff2c3398329bad262c8b7015e9cc720..64cf2b37ca37f46b70b5e5dc2bb0e699024ed779 100644 (file)
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <common/compat/time.h>
+#include <common/compat/time.hpp>
 #include <unistd.h>
 #include <signal.h>
 #include <sys/wait.h>
 
-#include <common/mi-lttng.h>
+#include <common/mi-lttng.hpp>
 
-#include "../command.h"
-#include "../utils.h"
+#include "../command.hpp"
+#include "../utils.hpp"
 
-#include <common/defaults.h>
-#include <common/sessiond-comm/sessiond-comm.h>
-#include <common/uri.h>
-#include <common/utils.h>
+#include <common/defaults.hpp>
+#include <common/sessiond-comm/sessiond-comm.hpp>
+#include <common/uri.hpp>
+#include <common/utils.hpp>
+#include <common/path.hpp>
 #include <lttng/lttng.h>
 
 static char *opt_output_path;
@@ -672,6 +673,11 @@ int cmd_create(int argc, const char **argv)
                        uint64_t v;
 
                        errno = 0;
+                       if (opt_arg) {
+                               free(opt_arg);
+                               opt_arg = nullptr;
+                       }
+
                        opt_arg = poptGetOptArg(pc);
                        if (!opt_arg) {
                                /* Set up default values. */
@@ -802,6 +808,7 @@ end:
        /* Overwrite ret if an error occurred in create_session() */
        ret = command_ret ? command_ret : ret;
 
+       free(opt_arg);
        poptFreeContext(pc);
        return ret;
 }
This page took 0.023661 seconds and 4 git commands to generate.