From ee051c40b73847be6c6e6867b291fc68a1adaa70 Mon Sep 17 00:00:00 2001 From: jinyaoguo Date: Thu, 22 May 2025 21:34:16 -0400 Subject: [PATCH] Add a check to prevent max_children from being 0. In function fetch_multiple and fetch_submodules, `multiple` is stored in `opt.process` and later used as a divisor in function `pp_collect_finished`, creating a potential divide-by-zero if it remains zero. Signed-off-by: Alex Guo --- builtin/fetch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index cda6eaf1fd6edc..b668187627a777 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -2591,7 +2591,7 @@ int cmd_fetch(int argc, die(_("--stdin can only be used when fetching " "from one remote")); - if (max_children < 0) + if (max_children <= 0) max_children = config.parallel; /* TODO should this also die if we have a previous partial-clone? */ @@ -2613,9 +2613,9 @@ int cmd_fetch(int argc, struct strvec options = STRVEC_INIT; int max_children = max_jobs; - if (max_children < 0) + if (max_children <= 0) max_children = config.submodule_fetch_jobs; - if (max_children < 0) + if (max_children <= 0) max_children = config.parallel; add_options_to_argv(&options, &config);