summaryrefslogtreecommitdiff
path: root/src/main-utils.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-03-19 16:28:59 +0100
committerThomas Haller <thaller@redhat.com>2015-03-20 11:43:29 +0100
commitb5ca5bd7b7e8894450786c0874a47620e777d3bb (patch)
treea43541d2dcd9c6efa9acda5ccecc26650372a2cd /src/main-utils.c
parent5e962bef878682c3821c1527758adbae4ee3e721 (diff)
downloadNetworkManager-b5ca5bd7b7e8894450786c0874a47620e777d3bb.tar.gz
main-utils: don't leak description for command line arguments in nm_main_utils_early_setup()
Diffstat (limited to 'src/main-utils.c')
-rw-r--r--src/main-utils.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main-utils.c b/src/main-utils.c
index 1c479d8a72..5a470fa0de 100644
--- a/src/main-utils.c
+++ b/src/main-utils.c
@@ -183,6 +183,8 @@ nm_main_utils_early_setup (const char *progname,
GError *error = NULL;
gboolean success = FALSE;
int i;
+ const char *opt_fmt_log_level = NULL, *opt_fmt_log_domains = NULL;
+ const char **opt_loc_log_level = NULL, **opt_loc_log_domains = NULL;
/* Make GIO ignore the remote VFS service; otherwise it tries to use the
* session bus to contact the remote service, and NM shouldn't ever be
@@ -207,10 +209,15 @@ nm_main_utils_early_setup (const char *progname,
}
for (i = 0; options[i].long_name; i++) {
- if (!strcmp (options[i].long_name, "log-level"))
+ if (!strcmp (options[i].long_name, "log-level")) {
+ opt_fmt_log_level = options[i].description;
+ opt_loc_log_level = &options[i].description;
options[i].description = g_strdup_printf (options[i].description, nm_logging_all_levels_to_string ());
- else if (!strcmp (options[i].long_name, "log-domains"))
+ } else if (!strcmp (options[i].long_name, "log-domains")) {
+ opt_fmt_log_domains = options[i].description;
+ opt_loc_log_domains = &options[i].description;
options[i].description = g_strdup_printf (options[i].description, nm_logging_all_domains_to_string ());
+ }
}
/* Parse options */
@@ -231,6 +238,15 @@ nm_main_utils_early_setup (const char *progname,
}
g_option_context_free (opt_ctx);
+ if (opt_loc_log_level) {
+ g_free ((char *) *opt_loc_log_level);
+ *opt_loc_log_level = opt_fmt_log_level;
+ }
+ if (opt_loc_log_domains) {
+ g_free ((char *) *opt_loc_log_domains);
+ *opt_loc_log_domains = opt_fmt_log_domains;
+ }
+
return success;
}