diff options
author | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:25:48 (EST) |
---|---|---|
committer | ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2008-12-15 00:25:48 (EST) |
commit | 9514ede74ec0bcb994a6f6dae3676accaff6cd97 (patch) | |
tree | 2e7fe689d508a718086ee9254cc62c19b11055e4 /libopkg | |
parent | e5e410f66035322b2e20d3c29de5baca0b2b5a60 (diff) |
opkg: fix some memory leak and double free issues.
git-svn-id: http://opkg.googlecode.com/svn/trunk@139 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg')
-rw-r--r-- | libopkg/opkg_cmd.c | 2 | ||||
-rw-r--r-- | libopkg/opkg_remove.c | 24 |
2 files changed, 17 insertions, 9 deletions
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 6eb01eb..fcf74f6 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -909,9 +909,9 @@ static int opkg_remove_cmd(opkg_conf_t *conf, int argc, char **argv) done = 0; - available = pkg_vec_alloc(); pkg_info_preinstall_check(conf); if ( argc > 0 ) { + available = pkg_vec_alloc(); pkg_hash_fetch_all_installed(&conf->pkg_hash, available); for (i=0; i < argc; i++) { pkg_name = malloc(strlen(argv[i])+2); diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c index c8cfb55..1debf21 100644 --- a/libopkg/opkg_remove.c +++ b/libopkg/opkg_remove.c @@ -90,7 +90,7 @@ int opkg_remove_dependent_pkgs (opkg_conf_t *conf, pkg_t *pkg, abstract_pkg_t ** int i; int a; int count; - pkg_vec_t *dependent_pkgs = pkg_vec_alloc(); + pkg_vec_t *dependent_pkgs; abstract_pkg_t * ab_pkg; if((ab_pkg = pkg->parent) == NULL){ @@ -110,6 +110,8 @@ int opkg_remove_dependent_pkgs (opkg_conf_t *conf, pkg_t *pkg, abstract_pkg_t ** i = 0; count = 1; + dependent_pkgs = pkg_vec_alloc(); + while (dependents [i] != NULL) { abstract_pkg_t *dep_ab_pkg = dependents[i]; @@ -131,16 +133,20 @@ int opkg_remove_dependent_pkgs (opkg_conf_t *conf, pkg_t *pkg, abstract_pkg_t ** * 2 - to keep track of pkgs whose deps have been checked alrdy - Karthik */ } - if (count == 1) - return 0; + if (count == 1) { + free(dependent_pkgs); + return 0; + } + int err=0; for (i = 0; i < dependent_pkgs->len; i++) { - int err = opkg_remove_pkg(conf, dependent_pkgs->pkgs[i],0); + err = opkg_remove_pkg(conf, dependent_pkgs->pkgs[i],0); if (err) - return err; + break; } - return 0; + free(dependent_pkgs); + return err; } static int user_prefers_removing_dependents(opkg_conf_t *conf, abstract_pkg_t *abpkg, pkg_t *pkg, abstract_pkg_t **dependents) @@ -268,8 +274,10 @@ int opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg,int message) /* remove packages depending on this package - Karthik */ err = opkg_remove_dependent_pkgs (conf, pkg, dependents); - free(dependents); - if (err) return err; + if (err) { + free(dependents); + return err; + } } if (dependents) free(dependents); |