summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-12-21 14:45:24 +0100
committerAllan McRae <allan@archlinux.org>2014-12-24 02:19:28 +0100
commitbf06efaa7831d9c18d6687f197303a688d843ca9 (patch)
treea04661b9831c5be682f31227528f40605823d179
parenteb7cc246c628acbd20e4f8a739682212c41ccf1a (diff)
downloadpacman-bf06efaa7831d9c18d6687f197303a688d843ca9.tar.gz
pacman-bf06efaa7831d9c18d6687f197303a688d843ca9.tar.xz
_alpm_delta_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/delta.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libalpm/delta.c b/lib/libalpm/delta.c
index baa02b75..23ca31d5 100644
--- a/lib/libalpm/delta.c
+++ b/lib/libalpm/delta.c
@@ -342,14 +342,18 @@ alpm_delta_t *_alpm_delta_dup(const alpm_delta_t *delta)
{
alpm_delta_t *newdelta;
CALLOC(newdelta, 1, sizeof(alpm_delta_t), return NULL);
- STRDUP(newdelta->delta, delta->delta, return NULL);
- STRDUP(newdelta->delta_md5, delta->delta_md5, return NULL);
- STRDUP(newdelta->from, delta->from, return NULL);
- STRDUP(newdelta->to, delta->to, return NULL);
+ STRDUP(newdelta->delta, delta->delta, goto error);
+ STRDUP(newdelta->delta_md5, delta->delta_md5, goto error);
+ STRDUP(newdelta->from, delta->from, goto error);
+ STRDUP(newdelta->to, delta->to, goto error);
newdelta->delta_size = delta->delta_size;
newdelta->download_size = delta->download_size;
return newdelta;
+
+error:
+ _alpm_delta_free(newdelta);
+ return NULL;
}
/* vim: set noet: */