[PATCH 09/11] gc: fix a memory leak
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 30, 2022, 18:00 UTC
- Message-ID
- <patch-09.11-b51a275b6b1-20220630T175714Z-avarab@gmail.com>
- In-Reply-To
- <cover-00.11-00000000000-20220630T175714Z-avarab@gmail.com>
Fix a memory leak in code added in 41abfe15d95 (maintenance: add pack-refs task, 2021-02-09), we need to call strvec_clear() on the "struct strvec" that we initialized.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- builtin/gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/builtin/gc.c b/builtin/gc.c index 021e9256ae2..eeff2b760e0 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -168,9 +168,15 @@ struct maintenance_run_opts; static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts) { struct strvec pack_refs_cmd = STRVEC_INIT; + int ret; + strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL); - return run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD); + ret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD); + + strvec_clear(&pack_refs_cmd); + + return ret; } static int too_many_loose_objects(void)
-- 2.37.0.874.g7d3439f13c4