diff options
author | Allan McRae <allan@archlinux.org> | 2014-12-21 15:08:24 +0100 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-12-24 02:19:29 +0100 |
commit | e89223420796739a1c52e64fcbffc011085d0e52 (patch) | |
tree | b95c1b728b635a769f7d14fe22d3cbbc20a093c9 /lib | |
parent | f4796c905ca70f87461feb8e1fca3dc4afbe1217 (diff) | |
download | pacman-e89223420796739a1c52e64fcbffc011085d0e52.tar.gz pacman-e89223420796739a1c52e64fcbffc011085d0e52.tar.xz |
_alpm_dep_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/deps.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index ca36270d..b12c6293 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -527,13 +527,17 @@ alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep) alpm_depend_t *newdep; CALLOC(newdep, 1, sizeof(alpm_depend_t), return NULL); - STRDUP(newdep->name, dep->name, return NULL); - STRDUP(newdep->version, dep->version, return NULL); - STRDUP(newdep->desc, dep->desc, return NULL); + STRDUP(newdep->name, dep->name, goto error); + STRDUP(newdep->version, dep->version, goto error); + STRDUP(newdep->desc, dep->desc, goto error); newdep->name_hash = dep->name_hash; newdep->mod = dep->mod; return newdep; + +error: + alpm_dep_free(newdep); + return NULL; } /* These parameters are messy. We check if this package, given a list of |