Skip to content

Commit 53537c6

Browse files
avargitster
authored andcommitted
bundle.c: don't leak the "args" in the "struct child_process"
Fix a leak that's been here since 7366096 (bundle API: change "flags" to be "extra_index_pack_args", 2021-09-05). If we can't verify the bundle, we didn't call child_process_clear() to clear the "args". But rather than adding an additional child_process_clear() call, let's verify the bundle before we start preparing the process we're going to spawn. If we fail to verify, we don't need to push anything to the child_process "args". Helped-by: Elijah Newren <[email protected]> Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2e5d75 commit 53537c6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bundle.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,10 @@ int unbundle(struct repository *r, struct bundle_header *header,
627627
enum verify_bundle_flags flags)
628628
{
629629
struct child_process ip = CHILD_PROCESS_INIT;
630+
631+
if (verify_bundle(r, header, flags))
632+
return -1;
633+
630634
strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
631635

632636
/* If there is a filter, then we need to create the promisor pack. */
@@ -638,8 +642,6 @@ int unbundle(struct repository *r, struct bundle_header *header,
638642
strvec_clear(extra_index_pack_args);
639643
}
640644

641-
if (verify_bundle(r, header, flags))
642-
return -1;
643645
ip.in = bundle_fd;
644646
ip.no_stdout = 1;
645647
ip.git_cmd = 1;

0 commit comments

Comments
 (0)