Skip to content

Commit 5d222c0

Browse files
rscharfegitster
authored andcommitted
receive-pack: avoid minor leak in case start_async() fails
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b945901 commit 5d222c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

builtin/receive-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,6 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, void *feed_sta
521521
proc.in = -1;
522522
proc.stdout_to_stderr = 1;
523523

524-
prepare_push_cert_sha1(&proc);
525-
526524
if (use_sideband) {
527525
memset(&muxer, 0, sizeof(muxer));
528526
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
533531
proc.err = muxer.in;
534532
}
535533

534+
prepare_push_cert_sha1(&proc);
535+
536536
code = start_command(&proc);
537537
if (code) {
538538
if (use_sideband)

0 commit comments

Comments
 (0)