builtin/log: fix leaking commit list in git-cherry(1)
We're storing the list of commits that git-cherry(1) is about to print into a temporary list. This list is never getting free'd and thus leaks. Fix this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
8ff6bd4750
commit
a282dbeba7
|
@ -2675,16 +2675,16 @@ int cmd_cherry(int argc, const char **argv, const char *prefix)
|
||||||
commit_list_insert(commit, &list);
|
commit_list_insert(commit, &list);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (list) {
|
for (struct commit_list *l = list; l; l = l->next) {
|
||||||
char sign = '+';
|
char sign = '+';
|
||||||
|
|
||||||
commit = list->item;
|
commit = l->item;
|
||||||
if (has_commit_patch_id(commit, &ids))
|
if (has_commit_patch_id(commit, &ids))
|
||||||
sign = '-';
|
sign = '-';
|
||||||
print_commit(sign, commit, verbose, abbrev, revs.diffopt.file);
|
print_commit(sign, commit, verbose, abbrev, revs.diffopt.file);
|
||||||
list = list->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_commit_list(list);
|
||||||
free_patch_ids(&ids);
|
free_patch_ids(&ids);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ checks that git cherry only returns the second patch in the local branch
|
||||||
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
|
||||||
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
|
||||||
|
|
||||||
|
TEST_PASSES_SANITIZE_LEAK=true
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
GIT_AUTHOR_EMAIL=bogus_email_address
|
GIT_AUTHOR_EMAIL=bogus_email_address
|
||||||
|
|
Loading…
Reference in New Issue