From d984eeeb47783aa1bf49b1d7d44fda7e1384c6fa Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 21 Dec 2015 17:50:13 +0100 Subject: [PATCH] xbps_symlink_target: fix bb977c7 (v2). --- lib/util.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/util.c b/lib/util.c index 5e9ab844..1c30f154 100644 --- a/lib/util.c +++ b/lib/util.c @@ -498,18 +498,20 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt) } else { res = strdup(p1 + strlen(xhp->rootdir)); } + assert(res); free(p1); + free(p); } if (res == NULL) { if (strcmp(xhp->rootdir, "/") == 0) { - res = strdup(p); + res = p; } else { res = strdup(p + strlen(xhp->rootdir)); + free(p); } } assert(res); free(lnk); - free(p); } else { /* absolute */ res = lnk;