From e89223420796739a1c52e64fcbffc011085d0e52 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Mon, 22 Dec 2014 00:08:24 +1000 Subject: _alpm_dep_dup: free memory on error Signed-off-by: Allan McRae --- lib/libalpm/deps.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/libalpm') 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 -- cgit v1.2.3-24-g4f1b