[gnome-software/wip/kalev/rhbz1632029] updates section: Fix a crash during automatic updates



commit 23995db974a186624b1bb0b1fc13fd2edf8eb2e9
Author: Kalev Lember <klember redhat com>
Date:   Sun Sep 23 19:11:13 2018 +0200

    updates section: Fix a crash during automatic updates
    
    When self->list is cleared, a bunch of variables pointing to items
    constructed in _build_section_header() become invalid. Make sure that we
    set those to NULL when self->list is cleared so that we can avoid using
    dangling pointers in callbacks.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1632029

 src/gs-updates-section.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/gs-updates-section.c b/src/gs-updates-section.c
index c17d5789..40ea5cc5 100644
--- a/src/gs-updates-section.c
+++ b/src/gs-updates-section.c
@@ -109,6 +109,14 @@ gs_updates_section_remove_all (GsUpdatesSection *self)
                GtkWidget *w = GTK_WIDGET (l->data);
                gtk_container_remove (GTK_CONTAINER (self), w);
        }
+
+       /* the following are set in _build_section_header(); clear these so
+        * that they don't become dangling pointers once all items are removed
+        * from self->list */
+       self->button = NULL;
+       self->button_cancel = NULL;
+       self->button_stack = NULL;
+
        gs_app_list_remove_all (self->list);
        gtk_widget_hide (GTK_WIDGET (self));
 }
@@ -503,6 +511,9 @@ gs_updates_section_progress_notify_cb (GsAppList *list,
                                       GParamSpec *pspec,
                                       GsUpdatesSection *self)
 {
+       if (self->button_cancel == NULL)
+               return;
+
        gs_progress_button_set_progress (GS_PROGRESS_BUTTON (self->button_cancel),
                                         gs_app_list_get_progress (list));
 }


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