[epiphany/gnome-3-18] embed: avoid memory corruption when clearing top widgets



commit d1f9edf31aa6f3b93e4ca3bf91b87382af10bdd5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Mar 4 13:28:19 2017 -0600

    embed: avoid memory corruption when clearing top widgets
    
    Don't call remove_from_destroy_list_cb, which modifies the destroy list,
    when already iterating through the list.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779180

 embed/ephy-embed.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index a0e9966..61e3d27 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -229,15 +229,6 @@ ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id)
 }
 
 static void
-ephy_embed_destroy_top_widgets (EphyEmbed *embed)
-{
-  GSList *iter;
-
-  for (iter = embed->priv->destroy_on_transition_list; iter; iter = iter->next)
-    gtk_widget_destroy (GTK_WIDGET (iter->data));
-}
-
-static void
 remove_from_destroy_list_cb (GtkWidget *widget, EphyEmbed *embed)
 {
   GSList *list;
@@ -248,7 +239,20 @@ remove_from_destroy_list_cb (GtkWidget *widget, EphyEmbed *embed)
 }
 
 static void
-ephy_embed_set_title (EphyEmbed *embed,
+ephy_embed_destroy_top_widgets (EphyEmbed *embed)
+{
+  GSList *iter;
+
+  for (iter = embed->priv->destroy_on_transition_list; iter; iter = iter->next) {
+    g_signal_handlers_disconnect_by_func (iter->data, remove_from_destroy_list_cb, embed);
+    gtk_widget_destroy (GTK_WIDGET (iter->data));
+  }
+
+  embed->priv->destroy_on_transition_list = NULL;
+}
+
+static void
+ephy_embed_set_title (EphyEmbed  *embed,
                       const char *title)
 {
   EphyEmbedPrivate *priv = embed->priv;


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