Fix leak in camel_folder_info_build()
authorJonathon Jongsma <jonathon@quotidian.org>
Fri, 6 Nov 2009 16:37:02 +0000 (10:37 -0600)
committerJonathon Jongsma <jonathon@quotidian.org>
Wed, 20 Jan 2010 21:57:36 +0000 (15:57 -0600)
All of the folders were added to a hash table with a non-strduped string as a
key, but then if the parent folder was missing, we created a new folderinfo for
the parent and inserted that into the hash table with a strduped key.  So when
the hash table was destroyed, the 'fake' parent folder keys were leaked.  To fix
this, I created the hash table with g_hash_table_new_full() which would g_free()
the keys and then always strduped the key.

https://bugzilla.gnome.org/show_bug.cgi?id=607588

camel/camel-store.c

index 9b8d26f..54ccac2 100644 (file)
@@ -1043,10 +1043,10 @@ camel_folder_info_build (GPtrArray *folders, const gchar *namespace,
        qsort (folders->pdata, folders->len, sizeof (folders->pdata[0]), folder_info_cmp);
 
        /* Hash the folders. */
-       hash = g_hash_table_new (g_str_hash, g_str_equal);
+       hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
        for (i = 0; i < folders->len; i++) {
                fi = folders->pdata[i];
-               g_hash_table_insert (hash, fi->full_name, fi);
+               g_hash_table_insert (hash, g_strdup (fi->full_name), fi);
        }
 
        /* Now find parents. */