From ae44f32be28e49358d4512d84eeebc291d1beeab Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Tue, 10 Nov 2015 11:58:07 +0100 Subject: [PATCH] lib/package_alternatives.c: fix memleak --- lib/package_alternatives.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/package_alternatives.c b/lib/package_alternatives.c index 5a386e32..35c8bf21 100644 --- a/lib/package_alternatives.c +++ b/lib/package_alternatives.c @@ -192,8 +192,11 @@ create_symlinks(struct xbps_handle *xhp, xbps_array_t a, const char *grname) xbps_set_cb_state(xhp, XBPS_STATE_ALTGROUP_LINK_ADDED, 0, NULL, "Creating '%s' alternatives group symlink: %s -> %s", grname, l, tgt); unlink(lnk); - if (tgt[0] == '/') - tgt = relpath(lnk + strlen(xhp->rootdir), tgt); + if (tgt[0] == '/') { + tgt_dup = relpath(lnk + strlen(xhp->rootdir), tgt); + free(tgt); + tgt = tgt_dup; + } if ((rv = symlink(tgt, lnk)) != 0) { xbps_dbg_printf(xhp, "failed to create alt symlink '%s'" "for group '%s': %s\n", lnk, grname,