From f6195c361709e0c0d7ccf7a9c6b8374b076879cb Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Wed, 10 Jul 2019 09:33:50 +0200 Subject: [PATCH] arrow-button: Remove timeout on dispose (Bug #15696) The blinking source timeout has a GDestroyNotify function associated that will update the button when the timeout is removed. But the timeout is removed on the button finalize, i.e. once the object is freed, which will lead to a crash trying to access memory already freed. I think the original author meant to use `dispose` instead of `finalize` for removing the blinking timeout. Signed-off-by: Olivier Fourdan --- libxfce4panel/xfce-arrow-button.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c index 0879a209..dc61d10f 100644 --- a/libxfce4panel/xfce-arrow-button.c +++ b/libxfce4panel/xfce-arrow-button.c @@ -74,7 +74,7 @@ static void xfce_arrow_button_get_property (GObject *o guint prop_id, GValue *value, GParamSpec *pspec); -static void xfce_arrow_button_finalize (GObject *object); +static void xfce_arrow_button_dispose (GObject *object); #if GTK_CHECK_VERSION (3, 0, 0) static gboolean xfce_arrow_button_draw (GtkWidget *widget, cairo_t *cr); @@ -132,7 +132,7 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass) gobject_class = G_OBJECT_CLASS (klass); gobject_class->get_property = xfce_arrow_button_get_property; gobject_class->set_property = xfce_arrow_button_set_property; - gobject_class->finalize = xfce_arrow_button_finalize; + gobject_class->dispose = xfce_arrow_button_dispose; gtkwidget_class = GTK_WIDGET_CLASS (klass); #if GTK_CHECK_VERSION (3, 0, 0) @@ -265,14 +265,17 @@ xfce_arrow_button_get_property (GObject *object, static void -xfce_arrow_button_finalize (GObject *object) +xfce_arrow_button_dispose (GObject *object) { XfceArrowButton *button = XFCE_ARROW_BUTTON (object); if (button->priv->blinking_timeout_id != 0) - g_source_remove (button->priv->blinking_timeout_id); + { + g_source_remove (button->priv->blinking_timeout_id); + button->priv->blinking_timeout_id = 0; + } - (*G_OBJECT_CLASS (xfce_arrow_button_parent_class)->finalize) (object); + (*G_OBJECT_CLASS (xfce_arrow_button_parent_class)->dispose) (object); } -- 2.18.1