[pacman-dev] [PATCH 3/3] lib/libalpm/deps.c: Fix memory leak in _alpm_splitdep() in case of error.
Diogo Sousa
diogogsousa at gmail.com
Sat Aug 27 17:03:47 EDT 2011
Signed-off-by: Diogo Sousa <diogogsousa at gmail.com>
---
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
More information about the pacman-dev
mailing list