Fix: sessiond: leak of config_path on duplicate --config option
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index db70a7cda2f7de830a07811f57e59252acd8cdab..aec2af425df1887b3d61d71a099dc732c026687c 100644 (file)
@@ -797,7 +797,7 @@ static int set_options(int argc, char **argv)
        int ret = 0, c = 0, option_index = 0;
        int orig_optopt = optopt, orig_optind = optind;
        char *optstring;
-       const char *config_path = NULL;
+       char *config_path = NULL;
 
        optstring = utils_generate_optstring(long_options,
                        sizeof(long_options) / sizeof(struct option));
@@ -821,6 +821,7 @@ static int set_options(int argc, char **argv)
                        WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
                                "-f, --config");
                } else {
+                       free(config_path);
                        config_path = utils_expand_path(optarg);
                        if (!config_path) {
                                ERR("Failed to resolve path: %s", optarg);
@@ -866,6 +867,7 @@ static int set_options(int argc, char **argv)
        }
 
 end:
+       free(config_path);
        free(optstring);
        return ret;
 }
This page took 0.024672 seconds and 4 git commands to generate.