Fix: sessiond: leak of config_path on duplicate --config option
[lttng-tools.git] / src / bin / lttng-sessiond / main.c
index 02e18a22c62942e5a8cb494b8cfbb218ae2e6503..1174162aa9ac8df25b4dcfc23994a95ac09e50bb 100644 (file)
@@ -856,7 +856,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));
@@ -880,6 +880,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);
@@ -925,6 +926,7 @@ static int set_options(int argc, char **argv)
        }
 
 end:
+       free(config_path);
        free(optstring);
        return ret;
 }
@@ -1331,7 +1333,7 @@ static void unregister_all_triggers(void)
        struct lttng_triggers *triggers = NULL;
        unsigned int trigger_count, i;
        const struct lttng_credentials creds = {
-                       .uid = LTTNG_OPTIONAL_INIT_VALUE(0),
+               .uid = LTTNG_OPTIONAL_INIT_VALUE(0),
        };
 
        DBG("Unregistering all triggers");
This page took 0.029468 seconds and 4 git commands to generate.