]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: fix leaking bloom filters
authorPatrick Steinhardt <ps@pks.im>
Tue, 5 Nov 2024 06:16:58 +0000 (07:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Nov 2024 06:37:52 +0000 (22:37 -0800)
The memory allocated by `prepare_to_use_bloom_filter()` is not released
by `release_revisions()`, causing a memory leak. Plug it.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c
t/t4216-log-bloom.sh

index f5f5b84f2b083657bcc98950b5c294314e52d37a..8df75b82249b36e7e3ee9a4a151f085c189acc45 100644 (file)
@@ -3227,6 +3227,11 @@ void release_revisions(struct rev_info *revs)
        clear_decoration(&revs->treesame, free);
        line_log_free(revs);
        oidset_clear(&revs->missing_commits);
+
+       for (int i = 0; i < revs->bloom_keys_nr; i++)
+               clear_bloom_key(&revs->bloom_keys[i]);
+       FREE_AND_NULL(revs->bloom_keys);
+       revs->bloom_keys_nr = 0;
 }
 
 static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
index 3f163dc396980f4dacce34b5209f50b870d5092f..8d22338f6aafe7f117643fd35f032403bdcf5a32 100755 (executable)
@@ -4,6 +4,7 @@ test_description='git log for a path with Bloom filters'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-chunk.sh