diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2013-12-09 11:07:47 -0500 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2013-12-09 12:28:45 -0500 |
commit | e4034ba27de725e0fa9b6c4de8f32ca7ad0193a3 (patch) | |
tree | c550355d8a93ae92a7bd7847a3001218c616270d /src/location-geoclue.c | |
parent | Constify gamma parameter to set_temperature() methods (diff) | |
download | redshift-ng-e4034ba27de725e0fa9b6c4de8f32ca7ad0193a3.tar.gz redshift-ng-e4034ba27de725e0fa9b6c4de8f32ca7ad0193a3.tar.bz2 redshift-ng-e4034ba27de725e0fa9b6c4de8f32ca7ad0193a3.tar.xz |
Do not allow NULL keys when setting options
This should fix a bug where command line options for the "manual" location
provider cannot override the config file. To keep compatability with previous
versions the command line parser will still special case parsing "-l LAT:LON"
and set the correct options in "manual".
Diffstat (limited to 'src/location-geoclue.c')
-rw-r--r-- | src/location-geoclue.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/location-geoclue.c b/src/location-geoclue.c index ebc0cde..6d33a59 100644 --- a/src/location-geoclue.c +++ b/src/location-geoclue.c @@ -18,6 +18,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <geoclue/geoclue-master.h> @@ -104,6 +105,8 @@ void location_geoclue_free(location_geoclue_state_t *state) { if (state->position != NULL) g_object_unref(state->position); + if (state->provider != NULL) free(state->provider); + if (state->provider_path != NULL) free(state->provider_path); } void @@ -131,32 +134,22 @@ location_geoclue_set_option(location_geoclue_state_t *state, const char *path = NULL; /* Parse string value */ - if (key != NULL && strcasecmp(key, "name") == 0) { - if (value != NULL && strcasecmp(value, "default") == 0) { + if (strcasecmp(key, "name") == 0) { + if (strcasecmp(value, "default") == 0) { provider = DEFAULT_PROVIDER; - } else if (value != NULL) { - provider = value; } else { - fputs(_("Must specify a provider `name' (or use `default').\n"), stderr); - return -1; + provider = value; } - /* TODO I don't think we own the string here, should be copied. */ - state->provider = provider; - } else if (key != NULL && strcasecmp(key, "path") == 0) { + state->provider = strdup(provider); + } else if (strcasecmp(key, "path") == 0) { if (value != NULL && strcasecmp(value, "default") == 0) { path = DEFAULT_PROVIDER_PATH; - } else if (value != NULL) { - path = value; } else { - fputs(_("Must specify a provider `path' (or use `default').\n"), stderr); - return -1; + path = value; } - /* TODO I don't think we own the string here, should be copied. */ - state->provider_path = path; - } else if (key == NULL) { - return -1; + state->provider_path = strdup(path); } else { fprintf(stderr, _("Unknown method parameter: `%s'.\n"), key); return -1; |