From: Michael Tremer Date: Sat, 25 Jan 2025 16:02:58 +0000 (+0000) Subject: xfer: Free and re-allocate the full URL X-Git-Tag: 0.9.30~379 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=020e6ed3a1e069ee9e50161591e8d0d5b8750518;p=pakfire.git xfer: Free and re-allocate the full URL This is necessary so that we won't carry over anything from the first run in case we have to update the URL later. Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/xfer.c b/src/pakfire/xfer.c index 43461e82..9a19e63a 100644 --- a/src/pakfire/xfer.c +++ b/src/pakfire/xfer.c @@ -403,12 +403,6 @@ int pakfire_xfer_create(struct pakfire_xfer** xfer, goto ERROR; } - // Allocate the full URL - x->fullurl = curl_url(); - if (!x->fullurl) { - r = -errno; - goto ERROR; - } // Setup the xfer r = pakfire_xfer_setup(x); @@ -1424,6 +1418,18 @@ static int pakfire_xfer_prepare_progress(struct pakfire_xfer* xfer, static int pakfire_xfer_prepare_url(struct pakfire_xfer* xfer) { int r; + // If this has been called before, we free the former object + if (xfer->fullurl) + curl_url_cleanup(xfer->fullurl); + + // Create a new URL object + xfer->fullurl = curl_url(); + if (!xfer->fullurl) { + ERROR(xfer->ctx, "Could not allocate a new URL: %m\n"); + r = -errno; + goto ERROR; + } + // Simply set absolute URLs if (pakfire_string_is_url(xfer->url)) { r = curl_url_set(xfer->fullurl, CURLUPART_URL, xfer->url, 0);