diff --git a/lib/util.c b/lib/util.c index 9889f261..bdf3da77 100644 --- a/lib/util.c +++ b/lib/util.c @@ -499,8 +499,8 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt) res = strdup(p1 + strlen(xhp->rootdir)); free(p1); } - } - if (res == NULL) { + free(p); + } else { if (strcmp(xhp->rootdir, "/") == 0) { res = p; } else {