summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-09-19 03:00:13 +0200
committerDan McGee <dan@archlinux.org>2009-09-22 18:46:32 -0500
commit0f834c93c7d33af8a828fc3753f46e92a868554f (patch)
treede437a502965d022f9b7e328b72d38f4611d177f
parent03470c51ca5350567d3ac5fcce2441307f742c84 (diff)
testdb : fix many memleaks
Yes, it was that bad :P We still have memleaks left because we cannot free the error data returned by libalpm, but pacman has the same issue. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--src/util/testdb.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/util/testdb.c b/src/util/testdb.c
index e521e6b3..6d351ebd 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -92,6 +92,11 @@ static int db_test(char *dbpath, int local)
}
}
}
+ if(closedir(dir)) {
+ fprintf(stderr, "error closing dbpath : %s\n", strerror(errno));
+ return(1);
+ }
+
return(ret);
}
@@ -110,6 +115,7 @@ int checkdeps(alpm_list_t *pkglist)
free(depstring);
ret++;
}
+ FREELIST(data);
return(ret);
}
@@ -125,6 +131,7 @@ int checkconflicts(alpm_list_t *pkglist)
alpm_conflict_get_package2(conflict));
ret++;
}
+ FREELIST(data);
return(ret);
}
@@ -163,21 +170,23 @@ int check_syncdbs(char *dbpath, alpm_list_t *dbnames) {
snprintf(syncdbpath, PATH_MAX, "%s/sync/%s", dbpath, dbname);
ret = db_test(syncdbpath, 0);
if(ret) {
- return(ret);
+ ret = 1;
+ goto cleanup;
}
db = alpm_db_register_sync(dbname);
if(db == NULL) {
fprintf(stderr, "error: could not register sync database (%s)\n",
alpm_strerrorlast());
- cleanup(EXIT_FAILURE);
+ ret = 1;
+ goto cleanup;
}
pkglist = alpm_db_get_pkgcache(db);
syncpkglist = alpm_list_join(syncpkglist, alpm_list_copy(pkglist));
}
ret += checkdeps(syncpkglist);
- alpm_list_free(syncpkglist);
- alpm_db_unregister_all();
+cleanup:
+ alpm_list_free(syncpkglist);
return(ret);
}
@@ -227,6 +236,7 @@ int main(int argc, char **argv)
ret = check_localdb(dbpath);
} else {
ret = check_syncdbs(dbpath,dbnames);
+ alpm_list_free(dbnames);
}
cleanup(ret);