]> git.ipfire.org Git - pakfire.git/commitdiff
xfer: Free and re-allocate the full URL
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 25 Jan 2025 16:02:58 +0000 (16:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 25 Jan 2025 16:02:58 +0000 (16:02 +0000)
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 <michael.tremer@ipfire.org>
src/pakfire/xfer.c

index 43461e825f73c80b6badcb28a2c1059ee3e871b3..9a19e63a3ac6c95ac9b6f8dd8d0c8ba96ad2e5fe 100644 (file)
@@ -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);