public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jeff King <peff@peff•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: Jacob Keller <jacob.e.keller@intel•com>,
	git@vger•kernel.org, Jacob Keller <jacob.keller@gmail•com>
Subject: Re: [PATCH] send-pack: clean up extra_have oid array
Date: Thu, 3 Jul 2025 11:40:47 -0400	[thread overview]
Message-ID: <20250703154047.GD1309870@coredump.intra.peff.net> (raw)
In-Reply-To: <xmqqzfdnkdx6.fsf@gitster.g>

On Tue, Jul 01, 2025 at 10:40:21AM -0700, Junio C Hamano wrote:

> There is an early exit from the function that would bypass these
> clean-up.  Perhaps something like this on top?
> 
>  builtin/send-pack.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git c/builtin/send-pack.c w/builtin/send-pack.c
> index b28da7ddd7..6ce9f6665a 100644
> --- c/builtin/send-pack.c
> +++ w/builtin/send-pack.c
> @@ -305,9 +305,10 @@ int cmd_send_pack(int argc,
>  		flags |= MATCH_REFS_MIRROR;
>  
>  	/* match them up */
> -	if (match_push_refs(local_refs, &remote_refs, &rs, flags))
> -		return -1;
> -
> +	if (match_push_refs(local_refs, &remote_refs, &rs, flags)) {
> +		ret = -1;
> +		goto cleanup;
> +	}
>  	if (!is_empty_cas(&cas))
>  		apply_push_cas(&cas, remote, remote_refs);
>  
> @@ -340,6 +341,7 @@ int cmd_send_pack(int argc,
>  		/* stable plumbing output; do not modify or localize */
>  		fprintf(stderr, "Everything up-to-date\n");
>  
> +cleanup:
>  	string_list_clear(&push_options, 0);
>  	free_refs(remote_refs);
>  	free_refs(local_refs);

This made me wonder if the remote_refs out-parameter is valid after
match_push_refs() returns failure (especially since we do not initialize
it at the top of the function).

I think the answer is "yes"; it is both an in-parameter and an
out-parameter, and will have been earlier set up via get_remote_heads().
So even on the failure case, match_push_refs() will leave it untouched
and it is still valid (and needs to be cleaned up).

-Peff

  parent reply	other threads:[~2025-07-03 15:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27 22:09 [PATCH] send-pack: clean up extra_have oid array Jacob Keller
2025-06-30 14:31 ` Junio C Hamano
2025-06-30 22:14   ` Jacob Keller
2025-07-01 17:40 ` Junio C Hamano
2025-07-01 20:36   ` Jacob Keller
2025-07-01 21:12     ` Junio C Hamano
2025-07-03 15:40   ` Jeff King [this message]
2025-07-03 16:26     ` Jacob Keller
2025-07-03 15:38 ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250703154047.GD1309870@coredump.intra.peff.net \
    --to=peff@peff$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=jacob.e.keller@intel$(echo .)com \
    --cc=jacob.keller@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox