receive-pack: avoid minor leak in case start_async() fails
authorRené Scharfe <l.s.r@web.de>
Tue, 28 Oct 2014 20:27:54 +0000 (21:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Oct 2014 21:55:15 +0000 (14:55 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c
index 42f25a5103a72486c46d7b3a584f249495dc12b4..99136526c91232382c773be45d13f79a32872a9a 100644 (file)
@@ -521,8 +521,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;
@@ -533,6 +531,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)