[gnome-control-center/gnome-3-26] network: Avoid crashing if NM reports no devices or no connections



commit 468f7bfc6b4d9c8aba01583dd9c06423730ddee7
Author: Rui Matos <tiagomatos gmail com>
Date:   Wed Nov 1 16:45:46 2017 +0100

    network: Avoid crashing if NM reports no devices or no connections
    
    Seems like NM changed behavior recently but, in any case, better safe
    than sorry.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=788716

 panels/network/cc-network-panel.c |    6 ++++--
 panels/network/cc-wifi-panel.c    |    7 +++++--
 2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index c33cef1..51ea823 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -915,8 +915,10 @@ cc_network_panel_init (CcNetworkPanel *panel)
 
         /* Cold-plug existing connections */
         connections = nm_client_get_connections (panel->client);
-        for (i = 0; i < connections->len; i++)
-                add_connection (panel, connections->pdata[i]);
+        if (connections) {
+                for (i = 0; i < connections->len; i++)
+                        add_connection (panel, connections->pdata[i]);
+        }
 
         g_debug ("Calling handle_argv() after cold-plugging connections");
         handle_argv (panel);
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index 38e65bb..4407ba7 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -141,8 +141,11 @@ load_wifi_devices (CcWifiPanel *self)
   devices = nm_client_get_devices (self->client);
 
   /* Cold-plug existing devices */
-  for (i = 0; i < devices->len; i++)
-    add_wifi_device (self, g_ptr_array_index (devices, i));
+  if (devices)
+    {
+      for (i = 0; i < devices->len; i++)
+        add_wifi_device (self, g_ptr_array_index (devices, i));
+    }
 
   check_main_stack_page (self);
 }


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