builtin/rev-list: fix leaking bitmap index when calculating disk usage

git-rev-list(1) can speed up its object size calculations for reachable
objects via a bitmap walk, if there is any bitmap. This is done in
`try_bitmap_disk_usage()`, which tries to optimistically load the bitmap
and then use it, if available. It never frees it though, leading to a
memory leak. Fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt 2024-06-11 11:19:55 +02:00 committed by Junio C Hamano
parent f644dc8494
commit 61f8bb1ec1
2 changed files with 4 additions and 0 deletions

View file

@ -508,6 +508,8 @@ static int try_bitmap_disk_usage(struct rev_info *revs,
size_from_bitmap = get_disk_usage_from_bitmap(bitmap_git, revs);
print_disk_usage(size_from_bitmap);
free_bitmap_index(bitmap_git);
return 0;
}

View file

@ -1,6 +1,8 @@
#!/bin/sh
test_description='basic tests of rev-list --disk-usage'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# we want a mix of reachable and unreachable, as well as