[gnome-control-center/wip/benzea/wifi-panel: 11/21] wifi: Fix invalid variant unref in connection editor



commit 41acf7650f3e40cf3b75b01dd512178beaf253c1
Author: Benjamin Berg <bberg redhat com>
Date:   Sat Dec 15 17:55:04 2018 +0100

    wifi: Fix invalid variant unref in connection editor
    
    If the WiFi secret is not set, then a NULL variant is passed back. We
    should not free this variant. Fix this by using g_autoptr instead.

 panels/network/connection-editor/net-connection-editor.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/panels/network/connection-editor/net-connection-editor.c 
b/panels/network/connection-editor/net-connection-editor.c
index 556b57fb8..2c8108ecd 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -448,20 +448,18 @@ get_secrets_cb (GObject *source_object,
 {
         NMRemoteConnection *connection;
         GetSecretsInfo *info = user_data;
-        GError *error = NULL;
-        GVariant *variant;
+        g_autoptr(GError) error = NULL;
+        g_autoptr(GVariant) variant = NULL;
 
         connection = NM_REMOTE_CONNECTION (source_object);
         variant = nm_remote_connection_get_secrets_finish (connection, res, &error);
 
         if (!variant && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
-                g_error_free (error);
                 g_free (info);
                 return;
         }
 
-        ce_page_complete_init (info->page, info->setting_name, variant, error);
-        g_variant_unref (variant);
+        ce_page_complete_init (info->page, info->setting_name, variant, g_steal_pointer (&error));
         g_free (info);
 }
 


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