diff options
| author | 2009-11-17 21:20:46 +0100 | |
|---|---|---|
| committer | 2009-11-19 18:13:36 +0100 | |
| commit | 804032e99f576b5cf9b1246f2b83857468e9c71b (patch) | |
| tree | c7cbe267a4354f67e0ff7842c5cd96940b288e96 | |
| parent | d503698b5e2c709fcf581a4c19f64bf36b6a1bea (diff) | |
| download | libplist-804032e99f576b5cf9b1246f2b83857468e9c71b.tar.gz libplist-804032e99f576b5cf9b1246f2b83857468e9c71b.tar.bz2 | |
don't leak GNodes in plist_free
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.
| -rw-r--r-- | src/plist.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plist.c b/src/plist.c index ed83e3c..1abd0f9 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -72,6 +72,7 @@ static void plist_free_node(GNode * node, gpointer none) | |||
| 72 | plist_free_data(data); | 72 | plist_free_data(data); |
| 73 | node->data = NULL; | 73 | node->data = NULL; |
| 74 | g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); | 74 | g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); |
| 75 | g_node_destroy(node); | ||
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | plist_t plist_new_dict(void) | 78 | plist_t plist_new_dict(void) |
| @@ -159,7 +160,6 @@ void plist_free(plist_t plist) | |||
| 159 | if (plist) | 160 | if (plist) |
| 160 | { | 161 | { |
| 161 | plist_free_node(plist, NULL); | 162 | plist_free_node(plist, NULL); |
| 162 | g_node_destroy(plist); | ||
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| 165 | 165 | ||
