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

Re: [PATCH 1/3] connect.c: Fix memory leak

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 10, 2015, 22:35 UTC
Message-ID
<xmqq61a8zdix.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1425920304-22360-1-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 15 quoted lines
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  connect.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/connect.c b/connect.c
> index ce0e121..6090211 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -739,6 +739,7 @@ struct child_process *git_connect(int fd[2], const char *url,
>  
>  				free(hostandport);
>  				free(path);
> +				free(conn);
>  				return NULL;

The lack of sufficient context in the patch made me wonder if merely freeing conn is sufficient or do we need some process related clean-up before freeing it.

It appears that this codepath is used only when debugging with CONNECT_DIAG_URL and we didn't start any process --- we only cleared it with a few arrays initialized to empty at this point of the code.

So it should be safe. I wish I didn't have to do the digging myself, though ;-)

>  			} else {
>  				ssh = getenv("GIT_SSH_COMMAND");
Previous: Torsten Bögershausen
Message 13 of 13 in “connect.c: Fix memory leak”
  1. 1/3 connect.c: Fix memory leakStefan Beller, Mar 9, 2015
  2. 2/3 bundle.c: fix memory leakStefan Beller, Mar 9, 2015
  3. Junio C HamanoMar 10, 2015
  4. Stefan BellerMar 10, 2015
  5. Junio C HamanoMar 10, 2015
  6. 2/3 bundle.c: fix memory leakStefan Beller, Mar 10, 2015
  7. Junio C HamanoMar 11, 2015
  8. 3/3 builtin/help.c: fix memory leakStefan Beller, Mar 9, 2015
  9. Junio C HamanoMar 10, 2015
  10. Stefan BellerMar 10, 2015
  11. Junio C HamanoMar 11, 2015
  12. Torsten BögershausenMar 9, 2015
  13. Junio C HamanoMar 10, 2015

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.