From 1360f530f1b2e1b703d28a19e643d4deec1f083a Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Dec 2009 00:30:41 +0100 Subject: Don't make config_file const in the config struct. Michael --- src/main.c | 9 ++++++++- src/main.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 8088b3c..a4b805b 100644 --- a/src/main.c +++ b/src/main.c @@ -215,6 +215,9 @@ process_cmdline (int argc, char **argv, struct config_s *conf) break; case 'c': + if (conf->config_file != NULL) { + safefree (conf->config_file); + } conf->config_file = safestrdup (optarg); if (!conf->config_file) { fprintf (stderr, @@ -305,7 +308,11 @@ static void initialize_config_defaults (struct config_s *conf) { memset (conf, 0, sizeof(*conf)); - conf->config_file = SYSCONFDIR "/tinyproxy.conf"; + conf->config_file = safestrdup (SYSCONFDIR "/tinyproxy.conf"); + if (!conf->config_file) { + fprintf (stderr, PACKAGE ": Could not allocate memory.\n"); + exit (EX_SOFTWARE); + } conf->godaemon = TRUE; /* * Make sure the HTML error pages array is NULL to begin with. diff --git a/src/main.h b/src/main.h index 6fc41b2..ed5ea8e 100644 --- a/src/main.h +++ b/src/main.h @@ -35,7 +35,7 @@ */ struct config_s { char *logf_name; - const char *config_file; + char *config_file; unsigned int syslog; /* boolean */ int port; char *stathost; -- cgit v1.2.3