Git fork

gc: fix a memory leak

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Ævar Arnfjörð Bjarmason and committed by
Junio C Hamano
55916bba 33d0dda6

+7 -1
+7 -1
builtin/gc.c
··· 168 168 static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts) 169 169 { 170 170 struct strvec pack_refs_cmd = STRVEC_INIT; 171 + int ret; 172 + 171 173 strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL); 172 174 173 - return run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD); 175 + ret = run_command_v_opt(pack_refs_cmd.v, RUN_GIT_CMD); 176 + 177 + strvec_clear(&pack_refs_cmd); 178 + 179 + return ret; 174 180 } 175 181 176 182 static int too_many_loose_objects(void)