Skip to content

Commit 55916bb

Browse files
avargitster
authored andcommitted
gc: fix a memory leak
Fix a memory leak in code added in 41abfe1 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 33d0dda commit 55916bb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

builtin/gc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,15 @@ struct maintenance_run_opts;
168168
static int maintenance_task_pack_refs(MAYBE_UNUSED struct maintenance_run_opts *opts)
169169
{
170170
struct strvec pack_refs_cmd = STRVEC_INIT;
171+
int ret;
172+
171173
strvec_pushl(&pack_refs_cmd, "pack-refs", "--all", "--prune", NULL);
172174

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;
174180
}
175181

176182
static int too_many_loose_objects(void)

0 commit comments

Comments
 (0)