summaryrefslogtreecommitdiff
path: root/panels/network/cc-wifi-panel.c
diff options
context:
space:
mode:
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2017-08-12 18:58:10 -0300
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>2017-08-12 18:58:10 -0300
commitfcf4e44ebddc1a8792f385cc6acfd5556d782375 (patch)
treeb04fd715de73f8dcae8feb428191eb6527aaf6e7 /panels/network/cc-wifi-panel.c
parente465010faa62db642bfaac693dbede6ebef891bc (diff)
downloadgnome-control-center-fcf4e44ebddc1a8792f385cc6acfd5556d782375.tar.gz
wifi: Don't access potentially invalid pointer
When the user launches Settings with a panel passed as argument, the following things happen: 1. The Wi-Fi panel starts loading. 2. The command line arguments are passed and the given panel is activated. 3. The Wi-Fi panel cancels the loading routine, and rfkill_proxy_acquired_cb() is called with the GError set as G_IO_ERROR_CANCELLED. 4. Crash in rfkill_proxy_acquired_cb(). The crash is caused because, when rfkill_proxy_acquired_cb() is called, the CcWifiPanel instance isn't valid anymore. And yet, the code tries to cast 'gpointer user_data' to a CcWifiPanel pointer. Fix that by only trying to cast anything after parsing the GError set by the callback.
Diffstat (limited to 'panels/network/cc-wifi-panel.c')
-rw-r--r--panels/network/cc-wifi-panel.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/panels/network/cc-wifi-panel.c b/panels/network/cc-wifi-panel.c
index f49993851..18ba1bac0 100644
--- a/panels/network/cc-wifi-panel.c
+++ b/panels/network/cc-wifi-panel.c
@@ -404,10 +404,12 @@ rfkill_proxy_acquired_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
{
- CcWifiPanel *self = CC_WIFI_PANEL (user_data);
- GError *error = NULL;
+ CcWifiPanel *self;
+ GDBusProxy *proxy;
+ GError *error;
- self->rfkill_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
+ error = NULL;
+ proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
if (error)
{
@@ -418,6 +420,10 @@ rfkill_proxy_acquired_cb (GObject *source_object,
return;
}
+ self = CC_WIFI_PANEL (user_data);
+
+ self->rfkill_proxy = proxy;
+
sync_airplane_mode_switch (self);
}