Skip to content

Commit

Permalink
don't leak GNodes in plist_free
Browse files Browse the repository at this point in the history
Before recursing over its children, plist_free_node started by
detaching the current GNode from its parent which means that
calling g_node_destroy on the root of the tree was freeing only
the top-level GNode while what was intended was to free the whole
tree. Don't leak memory by not detaching children GNodes from their
parents so that g_node_destroy on the toplevel GNode can clean
everything.
  • Loading branch information
Christophe Fergeau authored and JonathanBeck committed Nov 19, 2009
1 parent d503698 commit 804032e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/plist.c
Expand Up @@ -72,6 +72,7 @@ static void plist_free_node(GNode * node, gpointer none)
plist_free_data(data);
node->data = NULL;
g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL);
g_node_destroy(node);
}

plist_t plist_new_dict(void)
Expand Down Expand Up @@ -159,7 +160,6 @@ void plist_free(plist_t plist)
if (plist)
{
plist_free_node(plist, NULL);
g_node_destroy(plist);
}
}

Expand Down

0 comments on commit 804032e

Please sign in to comment.