Fixed two memory leaks when creating folderitems.
authorAndrej Kacian <ticho@claws-mail.org>
Fri, 9 Sep 2016 23:09:13 +0000 (01:09 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Fri, 9 Sep 2016 23:13:30 +0000 (01:13 +0200)
The Folderitem's "node" member is set to a new empty
GNode in folder_item_new(), but is later set to
another newly allocated GNode.

This commit removes the extra allocation in one case
(folder_new()), and gets rid of the original GNode
in another case, where avoiding the second allocation
is impossible without completely rewriting the recursive
folderitem appending in folder_get_from_xml().

src/folder.c

index b653bac..902b990 100644 (file)
@@ -192,7 +192,7 @@ Folder *folder_new(FolderClass *klass, const gchar *name, const gchar *path)
                return NULL;
        }
        item->folder = folder;
-       folder->node = item->node = g_node_new(item);
+       folder->node = item->node;
        folder->data = NULL;
 
        return folder;
@@ -4046,6 +4046,7 @@ static gpointer xml_to_folder_item(gpointer nodedata, gpointer data)
        }
 
        item = folder_item_new(folder, "", "");
+       g_node_destroy(item->node);
        if (folder->klass->item_set_xml != NULL)
                folder->klass->item_set_xml(folder, item, xmlnode->tag);
        else