]> Pileus Git - ~andy/gtk/commitdiff
gtkcssselector: Don't leak the hash table
authorJasper St. Pierre <jstpierre@mecheye.net>
Thu, 6 Dec 2012 22:38:06 +0000 (17:38 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 6 Dec 2012 22:39:09 +0000 (17:39 -0500)
We should probably free the memory we allocate. Sounds like a winning
strategy.

gtk/gtkcssselector.c

index ea7fc537ac35b444eedb0e786c1dd8f502d14133..0c70bf786c77b5cec776c50669c0a014503263c8 100644 (file)
@@ -1895,7 +1895,7 @@ alloc_tree (GByteArray *array, gint32 *offset)
 static gint32
 subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
 {
-  GHashTable *ht = gtk_css_selectors_count_initial_init ();
+  GHashTable *ht;
   GList *l;
   GList *matched;
   GList *remaining;
@@ -1912,6 +1912,8 @@ subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
   if (infos == NULL)
     return GTK_CSS_SELECTOR_TREE_EMPTY_OFFSET;
 
+  ht = gtk_css_selectors_count_initial_init ();
+
   for (l = infos; l != NULL; l = l->next)
     {
       info = l->data;
@@ -1989,6 +1991,7 @@ subdivide_infos (GByteArray *array, GList *infos, gint32 parent_offset)
 
   g_list_free (matched);
   g_list_free (remaining);
+  g_hash_table_free (ht);
 
   return tree_offset;
 }