aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-09-26 13:46:11 +0200
committerJunio C Hamano <gitster@pobox.com>2024-09-27 08:25:34 -0700
commit8f786a8e9fbbc8d110937a0ffdfe559f945aab50 (patch)
treefd087b434b88c81e85929c74787b13a9b9a43e74 /builtin/submodule--helper.c
parentsubmodule: fix leaking update strategy (diff)
downloadgit-8f786a8e9fbbc8d110937a0ffdfe559f945aab50.tar.gz
git-8f786a8e9fbbc8d110937a0ffdfe559f945aab50.zip
builtin/submodule--helper: clear child process when not running it
In `runcommand_in_submodule_cb()` we may end up not executing the child command when `argv` is empty. But we still populate the command with environment variables and other things, which needs cleanup. This leads to a memory leak because we do not call `finish_command()`. Fix this by clearing the child process when we don't execute it. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index ed05dc5134..fd1b679408 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -363,9 +363,13 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
if (!info->quiet)
printf(_("Entering '%s'\n"), displaypath);
- if (info->argv[0] && run_command(&cp))
- die(_("run_command returned non-zero status for %s\n."),
- displaypath);
+ if (info->argv[0]) {
+ if (run_command(&cp))
+ die(_("run_command returned non-zero status for %s\n."),
+ displaypath);
+ } else {
+ child_process_clear(&cp);
+ }
if (info->recursive) {
struct child_process cpr = CHILD_PROCESS_INIT;