From 3c458d22fdad10b41d810248c6a8efbe5b23f515 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Sat, 14 Feb 2009 18:49:17 +0100 Subject: Fix more memory leaks. --- src/bplist.c | 7 +++++++ src/plist.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bplist.c b/src/bplist.c index d848e6a..95070d7 100644 --- a/src/bplist.c +++ b/src/bplist.c @@ -285,6 +285,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec if (plist_get_node_type(size_node) != PLIST_UINT) return NULL; plist_get_uint_val(size_node, &size); + plist_free(size_node); } return parse_data_node(object, size); @@ -294,6 +295,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec if (plist_get_node_type(size_node) != PLIST_UINT) return NULL; plist_get_uint_val(size_node, &size); + plist_free(size_node); } return parse_string_node(object, size); @@ -303,6 +305,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec if (plist_get_node_type(size_node) != PLIST_UINT) return NULL; plist_get_uint_val(size_node, &size); + plist_free(size_node); } return parse_unicode_node(object, size); @@ -313,6 +316,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec if (plist_get_node_type(size_node) != PLIST_UINT) return NULL; plist_get_uint_val(size_node, &size); + plist_free(size_node); } return parse_array_node(object, size, dict_size); @@ -323,6 +327,7 @@ static plist_t parse_bin_node(char *object, uint8_t dict_size, char **next_objec if (plist_get_node_type(size_node) != PLIST_UINT) return NULL; plist_get_uint_val(size_node, &size); + plist_free(size_node); } return parse_dict_node(object, size, dict_size); default: @@ -868,6 +873,8 @@ void plist_to_bin(plist_t plist, char **plist_bin, uint32_t * length) //free intermediate objects g_hash_table_foreach_remove(ref_table, free_index, NULL); + g_ptr_array_free(objects, TRUE); + g_hash_table_destroy(ref_table); //write offsets offset_size = get_needed_bytes(bplist_buff->len); diff --git a/src/plist.c b/src/plist.c index c69f4c1..0e73c4b 100644 --- a/src/plist.c +++ b/src/plist.c @@ -65,6 +65,7 @@ static void plist_free_node(GNode * node, gpointer none) free(data); } node->data = NULL; + g_node_children_foreach(node, G_TRAVERSE_ALL, plist_free_node, NULL); } plist_t plist_new_dict() @@ -144,7 +145,7 @@ static plist_t plist_add_sub_element(plist_t node, plist_type type, const void * void plist_free(plist_t plist) { - g_node_children_foreach(plist, G_TRAVERSE_ALL, plist_free_node, NULL); + plist_free_node(plist, NULL); g_node_destroy(plist); } -- cgit v1.1-32-gdbae