test-read-midx: fix leak of bitmap_index struct

In read_midx_preferred_pack(), we open the bitmap index but never free
it. This isn't a big deal since this is just a test helper, and we exit
immediately after, but since we're trying to keep our leak-checking tidy
now, it's worth fixing.

Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2021-10-06 22:24:40 -04:00 committed by Junio C Hamano
parent 324efc90d1
commit e861b09636

View File

@ -85,11 +85,15 @@ static int read_midx_preferred_pack(const char *object_dir)
return 1; return 1;
bitmap = prepare_bitmap_git(the_repository); bitmap = prepare_bitmap_git(the_repository);
if (!(bitmap && bitmap_is_midx(bitmap))) if (!bitmap)
return 1; return 1;
if (!bitmap_is_midx(bitmap)) {
free_bitmap_index(bitmap);
return 1;
}
printf("%s\n", midx->pack_names[midx_preferred_pack(bitmap)]); printf("%s\n", midx->pack_names[midx_preferred_pack(bitmap)]);
free_bitmap_index(bitmap);
return 0; return 0;
} }