[network-manager-applet/jklimes/check-NMClient] mobile-wizard: fix a potential crash if nm_client_new() returns NULL



commit 7303ff1643a861bdad7b5f6d1d4c121fa8fdae56
Author: Jiří Klimeš <jklimes redhat com>
Date:   Fri Oct 11 13:24:10 2013 +0200

    mobile-wizard: fix a potential crash if nm_client_new() returns NULL

 src/libnm-gtk/nm-mobile-wizard.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/src/libnm-gtk/nm-mobile-wizard.c b/src/libnm-gtk/nm-mobile-wizard.c
index 9f586a0..86f7ddd 100644
--- a/src/libnm-gtk/nm-mobile-wizard.c
+++ b/src/libnm-gtk/nm-mobile-wizard.c
@@ -1260,7 +1260,7 @@ intro_add_initial_devices (NMAMobileWizard *self)
        gboolean selected_first = FALSE;
        int i;
 
-       devices = nm_client_get_devices (self->client);
+       devices = self->client ? nm_client_get_devices (self->client) : NULL;
        for (i = 0; devices && (i < devices->len); i++) {
                if (__intro_device_added (self, g_ptr_array_index (devices, i), !selected_first)) {
                        if (selected_first == FALSE)
@@ -1381,12 +1381,14 @@ intro_setup (NMAMobileWizard *self)
                GtkTreeIter iter;
 
                self->client = nm_client_new ();
-               g_signal_connect (self->client, "device-added",
-                                 G_CALLBACK (intro_device_added_cb), self);
-               g_signal_connect (self->client, "device-removed",
-                                 G_CALLBACK (intro_device_removed_cb), self);
-               g_signal_connect (self->client, "notify::manager-running",
-                                 G_CALLBACK (intro_manager_running_cb), self);
+               if (self->client) {
+                       g_signal_connect (self->client, "device-added",
+                                         G_CALLBACK (intro_device_added_cb), self);
+                       g_signal_connect (self->client, "device-removed",
+                                         G_CALLBACK (intro_device_removed_cb), self);
+                       g_signal_connect (self->client, "notify::manager-running",
+                                         G_CALLBACK (intro_manager_running_cb), self);
+               }
 
                self->dev_store = gtk_tree_store_new (3, G_TYPE_STRING, NM_TYPE_DEVICE, G_TYPE_BOOLEAN);
                self->dev_combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (self->dev_store));


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