talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 720b9a5429ea3ddfb5af01400eb67b9d2abac0a2
parent b274c72a2b5b7b482a48b75bee15d13eecf3d8cd
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sat, 10 Sep 2016 01:09:13 +0200

Fixed two memory leaks when creating folderitems.

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().

Diffstat:
Msrc/folder.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/folder.c b/src/folder.c @@ -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