bundle.c: don't leak the "args" in the "struct child_process"

Fix a leak that's been here since 7366096de9d (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 <newren@gmail.com> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Feb 7, 2023 at 00:07 UTC 53537c6c17737010b7090634257b6274347bdbc8
1 file changed +4 -2
bundle.c
+4 -2
@@ -627,6 +627,10 @@ int unbundle(struct repository *r, struct bundle_header *header,
627 enum verify_bundle_flags flags)
628 {
629 struct child_process ip = CHILD_PROCESS_INIT;
630 +
631 + if (verify_bundle(r, header, flags))
632 + return -1;
633 +
634 strvec_pushl(&ip.args, "index-pack", "--fix-thin", "--stdin", NULL);
635
636 /* 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,
642 strvec_clear(extra_index_pack_args);
643 }
644
641 - if (verify_bundle(r, header, flags))
642 - return -1;
645 ip.in = bundle_fd;
646 ip.no_stdout = 1;
647 ip.git_cmd = 1;