[pacman-dev] [PATCH] _alpm_dep_dup: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org> --- lib/libalpm/deps.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index ca36270..b12c629 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 -- 2.2.0
participants (1)
-
Allan McRae