From 8fe2c7a40a79c7d1b68bd00955729e94a21a0ea5 Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Fri, 30 Oct 2009 06:37:09 +0000 Subject: [PATCH] Fix some memory leaks. git-svn-id: http://opkg.googlecode.com/svn/trunk@229 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/nv_pair_list.c | 2 +- libopkg/opkg.c | 1 - libopkg/pkg_hash.c | 9 +++++---- libopkg/void_list.c | 6 ++---- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libopkg/nv_pair_list.c b/libopkg/nv_pair_list.c index fc4cd0f..e98d718 100644 --- a/libopkg/nv_pair_list.c +++ b/libopkg/nv_pair_list.c @@ -41,7 +41,7 @@ void nv_pair_list_deinit(nv_pair_list_t *list) /* malloced in nv_pair_list_append */ free(nv_pair); pos->data = NULL; - //free(pos); + free(pos); } void_list_deinit((void_list_t *) list); } diff --git a/libopkg/opkg.c b/libopkg/opkg.c index c6a86ea..5ff0eb5 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -1089,7 +1089,6 @@ int opkg_repository_accessibility_check(opkg_t *opkg) ret++; } str_list_elt_deinit(iter1); - free(iter1); } free(src); return ret; diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 5b7e3dd..dc9c3d0 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -576,10 +576,6 @@ pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,opkg_conf_ if(!ab_pkg->pkgs) ab_pkg->pkgs = pkg_vec_alloc(); - /* pkg_vec_insert_merge might munge package, but it returns an unmunged pkg */ - pkg = pkg_vec_insert_merge(ab_pkg->pkgs, pkg, set_status,conf ); - pkg->parent = ab_pkg; - if (buildProvides(hash, ab_pkg, pkg)<0){ fprintf(stderr, "%s : This should never happen. Report this Bug in bugzilla please \n ",__FUNCTION__); return NULL; @@ -595,6 +591,11 @@ pkg_t *hash_insert_pkg(hash_table_t *hash, pkg_t *pkg, int set_status,opkg_conf_ } buildDependedUponBy(pkg, ab_pkg); + + /* pkg_vec_insert_merge might munge package, but it returns an unmunged pkg */ + pkg = pkg_vec_insert_merge(ab_pkg->pkgs, pkg, set_status,conf ); + pkg->parent = ab_pkg; + return pkg; } diff --git a/libopkg/void_list.c b/libopkg/void_list.c index 676e3b1..1517228 100644 --- a/libopkg/void_list.c +++ b/libopkg/void_list.c @@ -30,7 +30,7 @@ int void_list_elt_init(void_list_elt_t *elt, void *data) void_list_elt_t * void_list_elt_new (void *data) { void_list_elt_t *elt; - /* freed in void_list_deinit */ + /* freed in void_list_elt_deinit */ elt = calloc(1, sizeof(void_list_elt_t)); if (elt == NULL) { fprintf(stderr, "%s: out of memory\n", __FUNCTION__); @@ -44,6 +44,7 @@ void void_list_elt_deinit(void_list_elt_t *elt) { list_del_init(&elt->node); void_list_elt_init(elt, NULL); + free(elt); } int void_list_init(void_list_t *list) @@ -59,8 +60,6 @@ void void_list_deinit(void_list_t *list) while (!void_list_empty(list)) { elt = void_list_pop(list); void_list_elt_deinit(elt); - /* malloced in void_list_append */ - free(elt); } INIT_LIST_HEAD(&list->head); } @@ -116,7 +115,6 @@ void *void_list_remove(void_list_t *list, void_list_elt_t **iter) *iter = list_entry(pos->node.prev, void_list_elt_t, node); void_list_elt_deinit(pos); - free(pos); return old_data; } -- 2.25.1