Subject: Re: [PATCH 21/28] http-push: free curl header lists

From: Patrick Steinhardt <[email-masked]>
Date: Thu, 26 Sep 2024 15:50:27 +0200

On Tue, Sep 24, 2024 at 06:05:50PM -0400, Jeff King wrote:
> 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