From 91067c05473b0ed4acdfe45321410c0d2963b25e Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 4 Feb 2016 09:55:46 +0100 Subject: [PATCH] xbps_symlink_target: fix bug introduced in b81b9ab. --- lib/util.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/util.c b/lib/util.c index bdf3da77..6c3b1381 100644 --- a/lib/util.c +++ b/lib/util.c @@ -492,24 +492,23 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt) free(p); p = xbps_sanitize_path(buf); assert(p); - if ((strstr(p, "./")) && (p1 = realpath(p, buf))) { + if ((strstr(p, "./")) && (p1 = realpath(p, NULL))) { if (strcmp(xhp->rootdir, "/") == 0) { - res = p1; + res = strdup(p1); } else { res = strdup(p1 + strlen(xhp->rootdir)); - free(p1); } - free(p); + free(p1); } else { if (strcmp(xhp->rootdir, "/") == 0) { - res = p; + res = strdup(p); } else { res = strdup(p + strlen(xhp->rootdir)); - free(p); } } assert(res); free(lnk); + free(p); } else { /* absolute */ res = lnk;