]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/rev-list: fix leaking bitmap index when calculating disk usage
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:19:55 +0000 (11:19 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:05 +0000 (13:15 -0700)
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>
builtin/rev-list.c
t/t6115-rev-list-du.sh

index 77803727e0765de41c04c5ff415964d30e0e1524..97d077a994363f7a7f8f0ee49deb6bd04324b4ea 100644 (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;
 }
 
index c0cfda62fa72e3581cdf596d19821c0a7941caf9..21c4a211b15a833efcfa2da67a29e072f6bf24fa 100755 (executable)
@@ -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