[gnome-shell] theme-node: Fix leak on stylesheet change.



commit 72bfa9125945919e9d69505d3e739480855f331e
Author: Hans Petter Jansson <hpj cl no>
Date:   Wed Jun 1 23:29:26 2016 +0200

    theme-node: Fix leak on stylesheet change.
    
    on_custom_stylesheet_changed() would set properties_computed to FALSE
    without freeing the old properties, then the properties pointer would
    be overwritten in ensure_properties().
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710230

 src/st/st-theme-node.c |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c
index 75df637..5582c75 100644
--- a/src/st/st-theme-node.c
+++ b/src/st/st-theme-node.c
@@ -67,10 +67,29 @@ st_theme_node_class_init (StThemeNodeClass *klass)
 }
 
 static void
+maybe_free_properties (StThemeNode *node)
+{
+  if (node->properties)
+    {
+      g_free (node->properties);
+      node->properties = NULL;
+      node->n_properties = 0;
+    }
+
+  if (node->inline_properties)
+    {
+      /* This destroys the list, not just the head of the list */
+      cr_declaration_destroy (node->inline_properties);
+      node->inline_properties = NULL;
+    }
+}
+
+static void
 on_custom_stylesheets_changed (StTheme *theme,
                                gpointer data)
 {
   StThemeNode *node = data;
+  maybe_free_properties (node);
   node->properties_computed = FALSE;
 }
 
@@ -119,18 +138,7 @@ st_theme_node_finalize (GObject *object)
   g_strfreev (node->pseudo_classes);
   g_free (node->inline_style);
 
-  if (node->properties)
-    {
-      g_free (node->properties);
-      node->properties = NULL;
-      node->n_properties = 0;
-    }
-
-  if (node->inline_properties)
-    {
-      /* This destroys the list, not just the head of the list */
-      cr_declaration_destroy (node->inline_properties);
-    }
+  maybe_free_properties (node);
 
   if (node->font_desc)
     {


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