[gnome-control-center/gnome-3-34] printers: Avoid read of freed memory



commit 8e687bf132b310e6095f22459cc35c398169f6b8
Author: Marek Kasik <mkasik redhat com>
Date:   Thu Jan 30 15:52:10 2020 +0100

    printers: Avoid read of freed memory
    
    This fixes an issue when on_get_job_attributes_cb()
    was called after Printers panel has been finished.
    It adds a GCancellable to pp_job_get_attributes_async()
    calls.

 panels/printers/cc-printers-panel.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 9fc0c7980..54d7213f7 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -95,6 +95,7 @@ struct _CcPrintersPanel
   GCancellable *subscription_renew_cancellable;
   GCancellable *actualize_printers_list_cancellable;
   GCancellable *cups_status_check_cancellable;
+  GCancellable *get_job_attributes_cancellable;
 
   gchar    *new_printer_name;
   gchar    *new_printer_location;
@@ -283,6 +284,7 @@ cc_printers_panel_dispose (GObject *object)
   g_cancellable_cancel (self->actualize_printers_list_cancellable);
   g_cancellable_cancel (self->cups_status_check_cancellable);
   g_cancellable_cancel (self->get_all_ppds_cancellable);
+  g_cancellable_cancel (self->get_job_attributes_cancellable);
 
   detach_from_cups_notifier (CC_PRINTERS_PANEL (object));
 
@@ -315,6 +317,7 @@ cc_printers_panel_dispose (GObject *object)
   g_clear_pointer (&self->printer_entries, g_hash_table_destroy);
   g_clear_pointer (&self->all_ppds_list, ppd_list_free);
   free_dests (self);
+  g_clear_object (&self->get_job_attributes_cancellable);
 
   G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
 }
@@ -471,7 +474,7 @@ on_cups_notification (GDBusConnection *connection,
       job = g_object_new (PP_TYPE_JOB, "id", job_id, NULL);
       pp_job_get_attributes_async (job,
                                    requested_attrs,
-                                   NULL,
+                                   self->get_job_attributes_cancellable,
                                    on_get_job_attributes_cb,
                                    self);
     }
@@ -1231,6 +1234,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
 
   self->actualize_printers_list_cancellable = g_cancellable_new ();
   self->cups_status_check_cancellable = g_cancellable_new ();
+  self->get_job_attributes_cancellable = g_cancellable_new ();
 
   builder_result = gtk_builder_add_objects_from_resource (self->builder,
                                                           "/org/gnome/control-center/printers/printers.ui",


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