summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/deps.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2014-12-22 08:42:41 +0100
committerAllan McRae <allan@archlinux.org>2014-12-24 02:19:29 +0100
commitc6dd581ec561af04e4e0edb07bcf74e4db17485a (patch)
tree9750070b39214139069f47a02dc8e46f22a59e23 /lib/libalpm/deps.c
parent27506aba8fe1e67bff7df47922d0e5fbba17b19f (diff)
downloadpacman-c6dd581ec561af04e4e0edb07bcf74e4db17485a.tar.gz
pacman-c6dd581ec561af04e4e0edb07bcf74e4db17485a.tar.xz
alpm_dep_from_string: free memory on error
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r--lib/libalpm/deps.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index b12c6293..d105a324 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -473,7 +473,7 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(const char *depstring)
/* Note the extra space in ": " to avoid matching the epoch */
if((desc = strstr(depstring, ": ")) != NULL) {
- STRDUP(depend->desc, desc + 2, return NULL);
+ STRDUP(depend->desc, desc + 2, goto error);
deplen = desc - depstring;
} else {
/* no description- point desc at NULL at end of string for later use */
@@ -513,13 +513,17 @@ alpm_depend_t SYMEXPORT *alpm_dep_from_string(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 error);
depend->name_hash = _alpm_hash_sdbm(depend->name);
if(version) {
- STRNDUP(depend->version, version, desc - version, return NULL);
+ STRNDUP(depend->version, version, desc - version, goto error);
}
return depend;
+
+error:
+ alpm_dep_free(depend);
+ return NULL;
}
alpm_depend_t *_alpm_dep_dup(const alpm_depend_t *dep)