diff --git a/bin/xbps-rindex/index-add.c b/bin/xbps-rindex/index-add.c index be98974f..0181c75d 100644 --- a/bin/xbps-rindex/index-add.c +++ b/bin/xbps-rindex/index-add.c @@ -209,14 +209,14 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force fprintf(stderr, "xbps-rindex: cannot lock repository " "%s: %s\n", repodir, strerror(errno)); rv = -1; - goto out; + goto earlyout; } repo = xbps_repo_public_open(xhp, repodir); if (repo == NULL && errno != ENOENT) { fprintf(stderr, "xbps-rindex: cannot open/lock repository " "%s: %s\n", repodir, strerror(errno)); rv = -1; - goto out; + goto earlyout; } if (repo) { idx = xbps_dictionary_copy_mutable(repo->idx); @@ -230,7 +230,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force fprintf(stderr, "xbps-rindex: cannot open/lock stage repository " "%s: %s\n", repodir, strerror(errno)); rv = -1; - goto out; + goto earlyout; } if (stage) { idxstage = xbps_dictionary_copy_mutable(stage->idx); @@ -277,6 +277,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force if (curpkgd == NULL) { if (errno && errno != ENOENT) { rv = errno; + xbps_object_release(binpkgd); free(pkgver); free(pkgname); goto out; @@ -322,12 +323,14 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force * - filename-sha256 */ if ((sha256 = xbps_file_hash(pkg)) == NULL) { + xbps_object_release(binpkgd); free(pkgver); free(pkgname); rv = EINVAL; goto out; } if (!xbps_dictionary_set_cstring(binpkgd, "filename-sha256", sha256)) { + xbps_object_release(binpkgd); free(sha256); free(pkgver); free(pkgname); @@ -336,18 +339,21 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force } free(sha256); if (stat(pkg, &st) == -1) { + xbps_object_release(binpkgd); free(pkgver); free(pkgname); rv = EINVAL; goto out; } if (!xbps_dictionary_set_uint64(binpkgd, "filename-size", (uint64_t)st.st_size)) { + xbps_object_release(binpkgd); free(pkgver); free(pkgname); rv = EINVAL; goto out; } if (set_build_date(binpkgd, st.st_mtime) < 0) { + xbps_object_release(binpkgd); free(pkgver); free(pkgname); rv = EINVAL; @@ -362,6 +368,7 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force * Add new pkg dictionary into the stage index */ if (!xbps_dictionary_set(idxstage, pkgname, binpkgd)) { + xbps_object_release(binpkgd); free(pkgname); free(pkgver); rv = EINVAL; @@ -382,6 +389,12 @@ index_add(struct xbps_handle *xhp, int args, int argmax, char **argv, bool force printf("index: %u packages registered.\n", xbps_dictionary_count(idx)); out: + xbps_object_release(idx); + xbps_object_release(idxstage); + if (idxmeta) + xbps_object_release(idxmeta); + +earlyout: if (repo) xbps_repo_close(repo); if (stage) diff --git a/lib/package_configure.c b/lib/package_configure.c index e279199b..0245426c 100644 --- a/lib/package_configure.c +++ b/lib/package_configure.c @@ -111,11 +111,11 @@ xbps_configure_pkg(struct xbps_handle *xhp, free(pkgname); return ENOENT; } + free(pkgname); rv = xbps_pkg_state_dictionary(pkgd, &state); xbps_dbg_printf(xhp, "%s: state %d rv %d\n", pkgver, state, rv); if (rv != 0) { - free(pkgname); xbps_dbg_printf(xhp, "%s: [configure] failed to get " "pkg state: %s\n", pkgver, strerror(rv)); return EINVAL; @@ -124,11 +124,9 @@ xbps_configure_pkg(struct xbps_handle *xhp, if (check_state) { if (state == XBPS_PKG_STATE_INSTALLED) { if ((xhp->flags & XBPS_FLAG_FORCE_CONFIGURE) == 0) { - free(pkgname); return 0; } } else if (state != XBPS_PKG_STATE_UNPACKED) { - free(pkgname); return EINVAL; } } diff --git a/lib/package_unpack.c b/lib/package_unpack.c index e99bfec4..23d48fb3 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -505,6 +505,7 @@ unpack_archive(struct xbps_handle *xhp, 0, pkgver, "%s: removed obsolete entry: %s", pkgver, file); xbps_object_release(obj); } + /* XXX: cant free obsoletes here, need to copy values before */ xbps_object_release(pkg_filesd); out: /* diff --git a/lib/transaction_shlibs.c b/lib/transaction_shlibs.c index f10df493..77de070b 100644 --- a/lib/transaction_shlibs.c +++ b/lib/transaction_shlibs.c @@ -132,6 +132,7 @@ collect_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs, bool req) } } xbps_object_iterator_release(iter); + xbps_object_release(pd); return d; } @@ -176,6 +177,7 @@ xbps_transaction_shlibs(struct xbps_handle *xhp, xbps_array_t pkgs, xbps_array_t xbps_object_release(array); } xbps_object_iterator_release(iter); + /* XXX: not possible to free shrequires without copying values */ xbps_object_release(shprovides); return unmatched;