ref-filter: plug memory leak in reach_filter()

21bf933928 (ref-filter: allow merged and no-merged filters, 2020-09-15)
added an early return to reach_filter().  Avoid leaking the memory of a
then unused array by postponing its allocation until we know we need it.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe 2020-09-26 10:37:29 +02:00 коммит произвёл Junio C Hamano
Родитель b59cdffd7e
Коммит 5336d50696
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -2239,12 +2239,14 @@ static void reach_filter(struct ref_array *array,
{ {
struct rev_info revs; struct rev_info revs;
int i, old_nr; int i, old_nr;
struct commit **to_clear = xcalloc(sizeof(struct commit *), array->nr); struct commit **to_clear;
struct commit_list *cr; struct commit_list *cr;
if (!check_reachable) if (!check_reachable)
return; return;
to_clear = xcalloc(sizeof(struct commit *), array->nr);
repo_init_revisions(the_repository, &revs, NULL); repo_init_revisions(the_repository, &revs, NULL);
for (i = 0; i < array->nr; i++) { for (i = 0; i < array->nr; i++) {