From: Nick Mathewson Date: Mon, 5 Nov 2012 02:51:02 +0000 (-0500) Subject: Clean up nonsensical calling convention for config_load_geoip_file_ X-Git-Tag: tor-0.2.4.6-alpha~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98204729aafbbce550fd51dd601690cf60226e60;p=thirdparty%2Ftor.git Clean up nonsensical calling convention for config_load_geoip_file_ (How many "load a file" functions do you typically see where the function frees the filename argument?) --- diff --git a/src/or/config.c b/src/or/config.c index be9144074a..338c670a54 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -5566,27 +5566,28 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg) } /** Load one of the geoip files, family determining which - * one. Note that fname will be freed by this - * function. default_fname is used if on Windows and + * one. default_fname is used if on Windows and * fname equals "". */ static void config_load_geoip_file_(sa_family_t family, - char *fname, /* will be freed */ + const char *fname, const char *default_fname) { - (void)default_fname; +#ifdef _WIN32 + char *free_fname = NULL; /* Used to hold any temporary-allocated value */ /* XXXX Don't use this "" junk; make our filename options * understand prefixes somehow. -NM */ - /* XXXX024 Reload GeoIPFile on SIGHUP. -NM */ -#ifdef _WIN32 - if (!strcmp(fname, "")) { - const char *conf_root = get_windows_conf_root(); - tor_free(fname); - tor_asprintf(&fname, "%s\\%s", conf_root, default_fname); - } + if (!strcmp(fname, "")) { + const char *conf_root = get_windows_conf_root(); + tor_asprintf(&free_fname, "%s\\%s", conf_root, default_fname); + fname = free_fname; + } + geoip_load_file(family, fname); + tor_free(free_fname); +#else + (void)default_fname; + geoip_load_file(family, fname); #endif - geoip_load_file(family, fname); - tor_free(fname); } /** Load geoip files for IPv4 and IPv6 if options and @@ -5595,14 +5596,16 @@ static void config_maybe_load_geoip_files_(const or_options_t *options, const or_options_t *old_options) { + /* XXXX024 Reload GeoIPFile on SIGHUP. -NM */ + if (options->GeoIPFile && ((!old_options || !opt_streq(old_options->GeoIPFile, options->GeoIPFile)) || !geoip_is_loaded(AF_INET))) - config_load_geoip_file_(AF_INET, tor_strdup(options->GeoIPFile), "geoip"); + config_load_geoip_file_(AF_INET, options->GeoIPFile, "geoip"); if (options->GeoIPv6File && ((!old_options || !opt_streq(old_options->GeoIPv6File, options->GeoIPv6File)) || !geoip_is_loaded(AF_INET6))) - config_load_geoip_file_(AF_INET6, tor_strdup(options->GeoIPv6File), "geoip6"); + config_load_geoip_file_(AF_INET6, options->GeoIPv6File, "geoip6"); }