{"thread":{"id":"37825","subject":"[PATCH] receive-pack: avoid minor leak in case start_async() fails","startedAt":"2014-10-28T20:27:54Z","lastAt":"2014-10-28T20:27:54Z","messageCount":1,"participants":["René Scharfe"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"251156","messageId":"544FFC4A.4010109@web.de","threadId":"37825","inReplyTo":null,"subject":"[PATCH] receive-pack: avoid minor leak in case start_async() fails","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2014-10-28T20:27:54Z","receivedAt":"2014-10-28T20:27:54Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"If the asynchronous start of copy_to_sideband() fails, then any\nenv_array entries added to struct child_process proc by\nprepare_push_cert_sha1() are leaked.  Call the latter function only\nafter start_async() succeeded so that the allocated entries are\ncleaned up automatically by start_command() or finish_command().\n\nSigned-off-by: Rene Scharfe <l.s.r@web.de>\n---\n builtin/receive-pack.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex fc03937..32fc540 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -527,8 +527,6 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta\n \tproc.in = -1;\n \tproc.stdout_to_stderr = 1;\n \n-\tprepare_push_cert_sha1(&proc);\n-\n \tif (use_sideband) {\n \t\tmemset(&muxer, 0, sizeof(muxer));\n \t\tmuxer.proc = copy_to_sideband;\n@@ -539,6 +537,8 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta\n \t\tproc.err = muxer.in;\n \t}\n \n+\tprepare_push_cert_sha1(&proc);\n+\n \tcode = start_command(&proc);\n \tif (code) {\n \t\tif (use_sideband)\n-- \n2.1.2\n"}]}