Signed-off-by: Diogo Sousa <[email protected]>
---
 lib/libalpm/deps.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 4c05191..1e24dbc 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -441,13 +441,20 @@ alpm_depend_t *_alpm_splitdep(const char *depstring)
        }
 
        /* copy the right parts to the right places */
-       STRNDUP(depend->name, depstring, ptr - depstring, return NULL);
+       STRNDUP(depend->name, depstring, ptr - depstring, goto error1);
        depend->name_hash = _alpm_hash_sdbm(depend->name);
        if(version) {
-               STRDUP(depend->version, version, return NULL);
+               STRDUP(depend->version, version, goto error2);
        }
 
        return depend;
+
+error2:
+       free(depend->name);
+error1:
+       free(depend);
+
+       return NULL;
 }
 
 alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)
-- 
1.7.6.1


Reply via email to