[pacman-dev] [PATCH] depmiss_new: free memory on error

Allan McRae allan at archlinux.org
Sun Dec 21 13:51:41 UTC 2014


Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/deps.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index f2ee8f4..ca36270 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -50,11 +50,15 @@ static alpm_depmissing_t *depmiss_new(const char *target, alpm_depend_t *dep,
 
 	MALLOC(miss, sizeof(alpm_depmissing_t), return NULL);
 
-	STRDUP(miss->target, target, return NULL);
+	STRDUP(miss->target, target, goto error);
 	miss->depend = _alpm_dep_dup(dep);
-	STRDUP(miss->causingpkg, causingpkg, return NULL);
+	STRDUP(miss->causingpkg, causingpkg, goto error);
 
 	return miss;
+
+error:
+	alpm_depmissing_free(miss);
+	return NULL;
 }
 
 void SYMEXPORT alpm_depmissing_free(alpm_depmissing_t *miss)
-- 
2.2.0


More information about the pacman-dev mailing list