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>
Ævar Arnfjörð Bjarmason committed
Jul 1, 2022 at 12:42 UTC
55916bba0f4805a3bd0c1891c48effbfe1d12536
1 file changed
+7
-1
builtin/gc.c
+7
-1
@@ -168,9 +168,15 @@ struct maintenance_run_opts;
168
static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
169
{
170
struct strvec pack_refs_cmd = STRVEC_INIT;
171
+ int ret;
172
+
173
strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
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;
180
}
181
182
static int too_many_loose_objects(void)