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

[PATCH] receive-pack: avoid minor leak in case start_async() fails

From
René Scharfe <l.s.r@web.de>
Date
Oct 28, 2014, 20:27 UTC
Message-ID
<544FFC4A.4010109@web.de>

If the asynchronous start of copy_to_sideband() fails, then any env_array entries added to struct child_process proc by prepare_push_cert_sha1() are leaked. Call the latter function only after start_async() succeeded so that the allocated entries are cleaned up automatically by start_command() or finish_command().

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/receive-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index fc03937..32fc540 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -527,8 +527,6 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
 	proc.in = -1;
 	proc.stdout_to_stderr = 1;
 
-	prepare_push_cert_sha1(&proc);
-
 	if (use_sideband) {
 		memset(&muxer, 0, sizeof(muxer));
 		muxer.proc = copy_to_sideband;
@@ -539,6 +537,8 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
 		proc.err = muxer.in;
 	}
 
+	prepare_push_cert_sha1(&proc);
+
 	code = start_command(&proc);
 	if (code) {
 		if (use_sideband)
-- 
2.1.2
Message 1 of 1 in “receive-pack: avoid minor leak in case start_async() fails”
  1. receive-pack: avoid minor leak in case start_async() failsRené Scharfe, Oct 28, 2014

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.