]> git.ipfire.org Git - thirdparty/git.git/commitdiff
connect: clear child process before freeing in diagnostic mode
authorJeff King <peff@peff.net>
Tue, 24 Sep 2024 21:51:24 +0000 (17:51 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Sep 2024 17:24:53 +0000 (10:24 -0700)
The git_connect() function has a special CONNECT_DIAG_URL mode, where we
stop short of actually connecting to the other side and just print some
parsing details. For URLs that require a child process (like ssh), we
free() the child_process struct but forget to clear it, leaking the
strings we stuffed into its "env" list.

This leak is triggered many times in t5500, which uses "fetch-pack
--diag-url", but we're not yet ready to mark it as leak-free.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
connect.c

index 6829ab397455c4df404364307d6bcfe79f0b0b0a..58f53d8dcbb87d4ec4e90a926ad3fadfec337d5d 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -1485,6 +1485,7 @@ struct child_process *git_connect(int fd[2], const char *url,
 
                                free(hostandport);
                                free(path);
+                               child_process_clear(conn);
                                free(conn);
                                strbuf_release(&cmd);
                                return NULL;