Fix: sessiond: leak of config_path on duplicate --config option
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 55e0ad3d7a28623cb6f1bdad7ccc04e289f410f8..e271640dba5a0412e42da8b39cd152fc50ce6323 100644 (file)
@@ -791,7 +791,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));
@@ -815,6 +815,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);
@@ -860,6 +861,7 @@ static int set_options(int argc, char **argv)
        }
 
 end:
+       free(config_path);
        free(optstring);
        return ret;
 }
This page took 0.024976 seconds and 5 git commands to generate.