Skip to content

Commit e69fe2e

Browse files
avargitster
authored andcommitted
merge-base: free() allocated "struct commit **" list
Fix a memory leak in 53eda89 (merge-base: teach "git merge-base" to drive underlying merge_bases_many(), 2008-07-30) by calling free() on the "struct commit **" list used by "git merge-base". This gets e.g. "t6010-merge-base.sh" closer to passing under SANITIZE=leak, it failed 8 tests before when compiled with that option, and now fails only 5 tests. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f2bcc69 commit e69fe2e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

builtin/merge-base.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
138138
int rev_nr = 0;
139139
int show_all = 0;
140140
int cmdmode = 0;
141+
int ret;
141142

142143
struct option options[] = {
143144
OPT_BOOL('a', "all", &show_all, N_("output all common ancestors")),
@@ -186,5 +187,7 @@ int cmd_merge_base(int argc, const char **argv, const char *prefix)
186187
ALLOC_ARRAY(rev, argc);
187188
while (argc-- > 0)
188189
rev[rev_nr++] = get_commit_reference(*argv++);
189-
return show_merge_base(rev, rev_nr, show_all);
190+
ret = show_merge_base(rev, rev_nr, show_all);
191+
free(rev);
192+
return ret;
190193
}

0 commit comments

Comments
 (0)