[gnome-bluetooth/gnome-3-28] settings: Handle calls to obex_agent_down during init



commit fe8d0ac49e95e846c832c7a597a76c9a7149ac71
Author: Andrea Azzarone <andrea azzarone canonical com>
Date:   Wed Mar 20 16:19:40 2019 +0000

    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

 lib/bluetooth-settings-obexpush.c | 14 +++++++++-----
 1 file 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]