xbps_symlink_target: fix a meamleak reported by clang-analyzer.

This commit is contained in:
Juan RP 2015-12-21 16:55:53 +01:00
parent a00c7b1c4b
commit bb977c73e4

View File

@ -502,14 +502,13 @@ xbps_symlink_target(struct xbps_handle *xhp, const char *path, const char *tgt)
} }
if (res == NULL) { if (res == NULL) {
if (strcmp(xhp->rootdir, "/") == 0) if (strcmp(xhp->rootdir, "/") == 0)
res = p; res = strdup(p);
else { else
res = strdup(p + strlen(xhp->rootdir)); res = strdup(p + strlen(xhp->rootdir));
free(p);
}
} }
assert(res); assert(res);
free(lnk); free(lnk);
free(p);
} else { } else {
/* absolute */ /* absolute */
res = lnk; res = lnk;