[gnome-control-center/gnome-3-28] printers: Fix crash when panel is closed quickly



commit 880bc9f39a7ae9a9c5901ecaff1b9584e74123c4
Author: Felipe Borges <felipeborges gnome org>
Date:   Mon Apr 9 11:42:35 2018 +0200

    printers: Fix crash when panel is closed quickly
    
    Fix a user-after-free while testing the connectivity to a cups
    server. This is similar to the fix in commit 1d72a0b.
    
    This is an addition to the changes introduced in commit 2ff5cfd
    which allowed the connection testing to be cancellable.
    
    Fixes #51
    Fixes https://bugzilla.gnome.org/794632

 panels/printers/cc-printers-panel.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 55a1682b4..b5d023929 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -1229,14 +1229,13 @@ connection_test_cb (GObject      *source_object,
                     gpointer      user_data)
 {
   CcPrintersPanelPrivate *priv;
-  CcPrintersPanel        *self = (CcPrintersPanel*) user_data;
+  CcPrintersPanel        *self;
   gboolean                success;
   PpCups                 *cups = PP_CUPS (source_object);
   g_autoptr(GError)       error = NULL;
 
-  priv = self->priv;
-
   success = pp_cups_connection_test_finish (cups, result, &error);
+  g_object_unref (cups);
 
   if (error != NULL)
     {
@@ -1244,15 +1243,18 @@ connection_test_cb (GObject      *source_object,
         {
           g_warning ("Could not test connection: %s", error->message);
         }
+
+      return;
     }
 
+  self = CC_PRINTERS_PANEL (user_data);
+  priv = self->priv;
+
   if (!success)
     {
       priv->cups_status_check_id =
         g_timeout_add_seconds (CUPS_STATUS_CHECK_INTERVAL, cups_status_check, self);
     }
-
-  g_object_unref (cups);
 }
 
 static void


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