diff options
| author | dequis <dx@dxzone.com.ar> | 2015-08-19 00:18:50 -0300 | 
|---|---|---|
| committer | dequis <dx@dxzone.com.ar> | 2015-08-19 00:23:44 -0300 | 
| commit | 49f11053bfaa539a8062c8f79cd7fc7b8fe8a191 (patch) | |
| tree | d7808db5a79a70e1a638908fb4612deb7b1fad5a | |
| parent | b39859ef33b55812992082f34fd9dab7263443f1 (diff) | |
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.
| -rw-r--r-- | conf.c | 31 | 
1 files changed, 30 insertions, 1 deletions
| @@ -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; | 
