summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Azzarone <andrea.azzarone@canonical.com>2019-03-20 16:19:40 +0000
committerBastien Nocera <hadess@hadess.net>2019-03-26 16:02:39 +0100
commit697e22f6fc3116edff74bcad5129c5fd2a4e5234 (patch)
tree3192059ebd6819ba7f1d37220f5b83a8dbcee582
parent2baa79c39b401b242cb802f03ade88ea49902572 (diff)
downloadgnome-bluetooth-697e22f6fc3116edff74bcad5129c5fd2a4e5234.tar.gz
settings: Handle calls to obex_agent_down during init
The function obex_agent_down (and consequently obex_agent_dispose) can be called while we are still waiting for the bus to be acquired. Add if-guards to ensure that we do try to reference invalid memory and/or handlers. Closes: https://gitlab.gnome.org/GNOME/gnome-control-center/issues/425
-rw-r--r--lib/bluetooth-settings-obexpush.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/bluetooth-settings-obexpush.c b/lib/bluetooth-settings-obexpush.c
index e9e4f4d3..e3ba0eef 100644
--- a/lib/bluetooth-settings-obexpush.c
+++ b/lib/bluetooth-settings-obexpush.c
@@ -771,14 +771,18 @@ obex_agent_dispose (GObject *obj)
{
ObexAgent *self = OBEX_AGENT (obj);
- g_dbus_connection_unregister_object (self->connection, self->object_reg_id);
- self->object_reg_id = 0;
+ if (self->object_reg_id != 0) {
+ g_dbus_connection_unregister_object (self->connection, self->object_reg_id);
+ self->object_reg_id = 0;
+ }
g_bus_unown_name (self->owner_id);
self->owner_id = 0;
- g_bus_unwatch_name (self->obexd_watch_id);
- self->obexd_watch_id = 0;
+ if (self->obexd_watch_id != 0) {
+ g_bus_unwatch_name (self->obexd_watch_id);
+ self->obexd_watch_id = 0;
+ }
g_clear_object (&client);
@@ -802,7 +806,7 @@ obex_agent_new (void)
void
obex_agent_down (void)
{
- if (agent != NULL) {
+ if (agent != NULL && agent->connection != NULL) {
g_dbus_connection_call (agent->connection,
MANAGER_SERVICE,
MANAGER_PATH,