]> git.ipfire.org Git - pakfire.git/commitdiff
httpclient: Initialize like everything else
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 09:28:20 +0000 (09:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 19 Oct 2024 09:28:20 +0000 (09:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/httpclient.c

index 4e068eba65ac250c9de5e994590da6f754a5b263..9fd9723b70868fa356e4627700638e99ec8d4430 100644 (file)
@@ -458,7 +458,7 @@ int pakfire_httpclient_create(struct pakfire_httpclient** client,
        // Allocate a new object
        c = calloc(1, sizeof(*c));
        if (!c)
-               return -ENOMEM;
+               return -errno;
 
        // Store reference to the context
        c->ctx = pakfire_ctx_ref(ctx);
@@ -487,13 +487,12 @@ int pakfire_httpclient_create(struct pakfire_httpclient** client,
        if (r)
                goto ERROR;
 
-       // Success
-       *client = c;
-
-       return 0;
+       // Return the pointer
+       *client = pakfire_httpclient_ref(c);
 
 ERROR:
-       pakfire_httpclient_free(c);
+       if (c)
+               pakfire_httpclient_unref(c);
 
        return r;
 }