Re: [PATCH 21/28] http-push: free curl header lists
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 26, 2024, 13:50 UTC
- Message-ID
- <ZvVmoz8StFi95VXR@pks.im>
- In-Reply-To
- <20240924220550.GU1143820@coredump.intra.peff.net>
On Tue, Sep 24, 2024 at 06:05:50PM -0400, Jeff King wrote:
Show 20 quoted lines
> diff --git a/http-push.c b/http-push.c
> index 52c53928a9..451f7d14bb 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -1398,6 +1400,7 @@ static int update_remote(const struct object_id *oid, struct remote_lock *lock)
> if (start_active_slot(slot)) {
> run_active_slot(slot);
> strbuf_release(&out_buffer.buf);
> + curl_slist_free_all(dav_headers);
> if (results.curl_result != CURLE_OK) {
> fprintf(stderr,
> "PUT error: curl result=%d, HTTP code=%ld\n",
> @@ -1407,6 +1410,7 @@ static int update_remote(const struct object_id *oid, struct remote_lock *lock)
> }
> } else {
> strbuf_release(&out_buffer.buf);
> + curl_slist_free_all(dav_headers);
> fprintf(stderr, "Unable to start PUT request\n");
> return 0;
> }I was quite confused by the layout of this function, where we had another `return 1` at the end. It took me a second to realize that this is the error case for the `if (start_active_slot(slot))` condition further up. But we do already free the headers in that case, so we're good.
Patric