[pacman-dev] [PATCH 2/4] apply_deltas: fix memory leak on error
Allan McRae
allan at archlinux.org
Wed Dec 24 02:14:01 UTC 2014
Signed-off-by: Allan McRae <allan at archlinux.org>
---
lib/libalpm/sync.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 3664675..e19655d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -736,11 +736,11 @@ static int apply_deltas(alpm_handle_t *handle)
} else {
/* len = cachedir len + from len + '/' + null */
len = strlen(cachedir) + strlen(d->from) + 2;
- MALLOC(from, len, RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(from, len, free(delta); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(from, len, "%s/%s", cachedir, d->from);
}
len = strlen(cachedir) + strlen(d->to) + 2;
- MALLOC(to, len, free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
+ MALLOC(to, len, free(delta); free(from); RET_ERR(handle, ALPM_ERR_MEMORY, 1));
snprintf(to, len, "%s/%s", cachedir, d->to);
/* build the patch command */
--
2.2.1
More information about the pacman-dev
mailing list