From ada3483acca3170a1dd6940a3ff7f9a02431de1e Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 19 Apr 2014 16:07:29 +0200 Subject: [PATCH] lib/repo.c: fix two memleaks in error paths found by clang. --- lib/repo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/repo.c b/lib/repo.c index 8cfdbc2c..ef5e4d59 100644 --- a/lib/repo.c +++ b/lib/repo.c @@ -80,6 +80,9 @@ repo_get_dict(struct xbps_repo *repo) if (rv == ARCHIVE_EOF) break; if (rv != ARCHIVE_OK) { + if (adata != NULL) + free(adata); + xbps_dbg_printf(repo->xhp, "%s: read_data_block %s\n", repo->uri, archive_error_string(repo->ar)); @@ -128,8 +131,10 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url) /* remote repository */ char *rpath; - if ((rpath = xbps_get_remote_repo_string(url)) == NULL) + if ((rpath = xbps_get_remote_repo_string(url)) == NULL) { + free(repo); return NULL; + } repofile = xbps_xasprintf("%s/%s/%s-repodata", xhp->metadir, rpath, arch); free(rpath); repo->is_remote = true;