Subject: Re: [PATCH 3/4] remote: fix leak in branch_get_push_1() with invalid "simple" config

From: Patrick Steinhardt <[email-masked]>
Date: Mon, 19 Jan 2026 07:34:08 +0100

On Mon, Jan 19, 2026 at 12:22:08AM -0500, Jeff King wrote:
> diff --git a/remote.c b/remote.c
> index 5de9619bc7..e191b0ff6e 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -1938,9 +1938,11 @@ static const char *branch_get_push_1(struct repository *repo,
>  			cur = tracking_for_push_dest(remote, branch->refname, err);
>  			if (!cur)
>  				return NULL;
> -			if (strcmp(cur, up))
> +			if (strcmp(cur, up)) {
> +				free(cur);
>  				return error_buf(err,
>  						 _("cannot resolve 'simple' push to a single destination"));
> +			}

Yup, this memory leak was easy to spot in the preceding commit after
your refactorings.

Patrick