diff options
author | Jon Lund Steffensen <jonlst@gmail.com> | 2011-07-12 22:30:30 +0200 |
---|---|---|
committer | Jon Lund Steffensen <jonlst@gmail.com> | 2011-07-12 22:30:30 +0200 |
commit | 8a0eee83de8d164cb49339a1886f3e49c50a71cc (patch) | |
tree | c32e781fc985bedf2acf1d793bf2d5fef3a18c3e /src/location-geoclue.c | |
parent | Fix build on windows platform. (diff) | |
download | redshift-ng-8a0eee83de8d164cb49339a1886f3e49c50a71cc.tar.gz redshift-ng-8a0eee83de8d164cb49339a1886f3e49c50a71cc.tar.bz2 redshift-ng-8a0eee83de8d164cb49339a1886f3e49c50a71cc.tar.xz |
location-geoclue: Check return value of geoclue_master_create_client().
Unref master and client objects after use.
Diffstat (limited to 'src/location-geoclue.c')
-rw-r--r-- | src/location-geoclue.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/location-geoclue.c b/src/location-geoclue.c index 6946dd8..4050f41 100644 --- a/src/location-geoclue.c +++ b/src/location-geoclue.c @@ -50,14 +50,20 @@ location_geoclue_init(location_geoclue_state_t *state) int location_geoclue_start(location_geoclue_state_t *state) { - GeoclueMaster *master = NULL; - GeoclueMasterClient *client = NULL; - GError *error = NULL; - gchar *name = NULL; - - if (!(state->provider && state->provider_path)) { - master = geoclue_master_get_default(); - client = geoclue_master_create_client(master, NULL, NULL); + if (state->provider && state->provider_path) { + state->position = geoclue_position_new(state->provider, + state->provider_path); + } else { + GeoclueMaster *master = geoclue_master_get_default(); + GeoclueMasterClient *client = geoclue_master_create_client(master, + NULL, NULL); + GError *error = NULL; + + if (client == NULL) { + g_printerr(_("Unable to obtain master client.\n")); + g_object_unref(master); + return -1; + } if (!geoclue_master_client_set_requirements(client, GEOCLUE_ACCURACY_LEVEL_REGION, @@ -68,15 +74,18 @@ location_geoclue_start(location_geoclue_state_t *state) error->message); g_error_free(error); g_object_unref(client); + g_object_unref(master); return -1; } state->position = geoclue_master_client_create_position(client, NULL); - } else { - state->position = geoclue_position_new(state->provider, - state->provider_path); - } + + g_object_unref(client); + g_object_unref(master); + } + + gchar *name = NULL; if (geoclue_provider_get_provider_info(GEOCLUE_PROVIDER(state->position), &name, NULL, NULL)) { |