From e29f2216e235c082296a9553cac11c524a5f81ac Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 4 Apr 2013 09:55:12 +0200 Subject: [PATCH] xbps-rindex: fix memleaks in error paths. --- bin/xbps-rindex/index-add.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/xbps-rindex/index-add.c b/bin/xbps-rindex/index-add.c index f5d3a502..525edfcc 100644 --- a/bin/xbps-rindex/index-add.c +++ b/bin/xbps-rindex/index-add.c @@ -64,8 +64,11 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) repodir = dirname(tmprepodir); /* Internalize index or create it if doesn't exist */ - if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL) + if ((plist = xbps_pkg_index_plist(xhp, repodir)) == NULL) { + free(tmprepodir); return -1; + } + free(tmprepodir); if ((idx = prop_dictionary_internalize_from_zfile(plist)) == NULL) { if (errno != ENOENT) { @@ -130,6 +133,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) curpkgd = prop_dictionary_get(idx, pkgname); if (curpkgd == NULL) { if (errno && errno != ENOENT) { + free(tmpfilen); free(pkgver); free(pkgname); return errno; @@ -165,12 +169,14 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) * objects for the index. */ if ((sha256 = xbps_file_hash(argv[i])) == NULL) { + free(tmpfilen); free(pkgver); free(pkgname); return errno; } if (!prop_dictionary_set_cstring(newpkgd, "filename-sha256", sha256)) { + free(tmpfilen); free(pkgver); free(pkgname); return errno; @@ -178,6 +184,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) free(sha256); if (stat(argv[i], &st) == -1) { + free(tmpfilen); free(pkgver); free(pkgname); return errno; @@ -185,6 +192,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) if (!prop_dictionary_set_uint64(newpkgd, "filename-size", (uint64_t)st.st_size)) { + free(tmpfilen); free(pkgver); free(pkgname); return errno; @@ -209,6 +217,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv) * Add new pkg dictionary into the index. */ if (!prop_dictionary_set(idx, pkgname, newpkgd)) { + free(tmpfilen); free(pkgname); return EINVAL; }