From 49f11053bfaa539a8062c8f79cd7fc7b8fe8a191 Mon Sep 17 00:00:00 2001 From: dequis Date: Wed, 19 Aug 2015 00:18:50 -0300 Subject: conf: Fix leak of members of conf_t when using -c to specify a config Can only happen once, and it's just ~200 bytes. But being valgrind-clean is good. --- conf.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'conf.c') diff --git a/conf.c b/conf.c index e17fd172..5df2cecc 100644 --- a/conf.c +++ b/conf.c @@ -36,6 +36,7 @@ #include "proxy.h" static int conf_loadini(conf_t *conf, char *file); +static void conf_free(conf_t *conf); conf_t *conf_load(int argc, char *argv[]) { @@ -103,7 +104,7 @@ conf_t *conf_load(int argc, char *argv[]) if (strcmp(global.conf_file, optarg) != 0) { g_free(global.conf_file); global.conf_file = g_strdup(optarg); - g_free(conf); + conf_free(conf); /* Re-evaluate arguments. Don't use this option twice, you'll end up in an infinite loop! Hope this trick works with all libcs BTW.. */ @@ -167,6 +168,34 @@ conf_t *conf_load(int argc, char *argv[]) return conf; } +static void conf_free(conf_t *conf) +{ + /* Free software means users have the four essential freedoms: + 0. to run the program, + 2. to study and change the program in source code form, + 2. to redistribute exact copies, and + 3. to distribute modified versions + */ + g_free(conf->auth_pass); + g_free(conf->cafile); + g_free(conf->configdir); + g_free(conf->ft_listen); + g_free(conf->hostname); + g_free(conf->iface_in); + g_free(conf->iface_out); + g_free(conf->motdfile); + g_free(conf->oper_pass); + g_free(conf->pidfile); + g_free(conf->plugindir); + g_free(conf->port); + g_free(conf->primary_storage); + g_free(conf->user); + g_strfreev(conf->migrate_storage); + g_strfreev(conf->protocols); + g_free(conf); + +} + static int conf_loadini(conf_t *conf, char *file) { ini_t *ini; -- cgit v1.2.3