git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin/fetch-pack: cleanup before return error

From
Patrick Steinhardt <ps@pks.im>
Date
Jun 4, 2025, 07:58 UTC
Message-ID
<aD_8tafSPGhtdQI0@pks.im>
In-Reply-To
<pull.1990.git.git.1749006474694.gitgitgadget@gmail.com>
On Wed, Jun 04, 2025 at 03:07:54AM +0000, Lidong Yan via GitGitGadget wrote:
Show 25 quoted lines
> diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
> index d07eec9e555..d9e42bad584 100644
> --- a/builtin/fetch-pack.c
> +++ b/builtin/fetch-pack.c
> @@ -274,8 +274,10 @@ int cmd_fetch_pack(int argc,
>  	}
>  	close(fd[0]);
>  	close(fd[1]);
> -	if (finish_connect(conn))
> -		return 1;
> +	if (finish_connect(conn)) {
> +		ret = 1;
> +		goto cleanup;
> +	}
>  
>  	ret = !fetched_refs;
>  
> @@ -291,6 +293,7 @@ int cmd_fetch_pack(int argc,
>  		printf("%s %s\n",
>  		       oid_to_hex(&ref->old_oid), ref->name);
>  
> +cleanup:
>  	for (size_t i = 0; i < nr_sought; i++)
>  		free_one_ref(sought_to_free[i]);
>  	free(sought_to_free);

Sensible again. My only worry is that some of the variables that get free'd here may not have been initialized. But I went through all of them and all of them are NULL- or zero-initialized indeed, so this looks good to me. Thanks!

Patrick
Previous: Lidong Yan via GitGitGadget
Message 2 of 2 in “builtin/fetch-pack: cleanup before return error”
  1. builtin/fetch-pack: cleanup before return errorLidong Yan via GitGitGadget, Jun 4, 2025
  2. Patrick SteinhardtJun 4, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.