Skip to content

Commit

Permalink
receive-pack: avoid minor leak in case start_async() fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Oct 28, 2014
1 parent b945901 commit 5d222c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builtin/receive-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down

0 comments on commit 5d222c0

Please sign in to comment.