]> Kevux Git Server - rit/commitdiff
blame: fix leaking data for blame scoreboards
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:21:20 +0000 (11:21 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:08 +0000 (13:15 -0700)
There are some memory leaks when cleaning up blame scoreboards. Fix
those.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
blame.c
t/t4061-diff-indent.sh
t/t8002-blame.sh
t/t8004-blame-with-conflicts.sh
t/t8006-blame-textconv.sh
t/t8009-blame-vs-topicbranches.sh
t/t8011-blame-split-file.sh
t/t8012-blame-colors.sh
t/t8014-blame-ignore-fuzzy.sh

diff --git a/blame.c b/blame.c
index 33586b9..f97d0e9 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -2928,6 +2928,10 @@ void setup_blame_bloom_data(struct blame_scoreboard *sb)
 
 void cleanup_scoreboard(struct blame_scoreboard *sb)
 {
+       free(sb->lineno);
+       clear_prio_queue(&sb->commits);
+       oidset_clear(&sb->ignore_list);
+
        if (sb->bloom_data) {
                int i;
                for (i = 0; i < sb->bloom_data->nr; i++) {
index 7750b87..2942e5d 100755 (executable)
@@ -6,6 +6,7 @@ test_description='Test diff indent heuristic.
 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-diff.sh
 
index 0147de3..3596634 100755 (executable)
@@ -5,6 +5,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
 TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 PROG='git blame -c'
index 35414a5..2c2a0b3 100755 (executable)
@@ -6,6 +6,7 @@ test_description='git blame on conflicted files'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup first case' '
index 7683515..42f8be2 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='git blame textconv support'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 find_blame() {
index 72596e3..3033171 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='blaming trough history with topic branches'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # Creates the history shown below. '*'s mark the first parent in the merges.
index bdda0c0..da1801f 100755 (executable)
@@ -10,6 +10,8 @@ Note that we need to use "blame -C" to find the commit for all lines. We will
 not bother testing that the non-C case fails to find it. That is how blame
 behaves now, but it is not a property we want to make sure is retained.
 '
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 # help avoid typing and reading long strings of similar lines
index c3a5f6d..9a79c10 100755 (executable)
@@ -5,6 +5,7 @@ GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
 TEST_CREATE_REPO_NO_TEMPLATE=1
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 PROG='git blame -c'
index 0bd0341..933222c 100755 (executable)
@@ -1,6 +1,8 @@
 #!/bin/sh
 
 test_description='git blame ignore fuzzy heuristic'
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 pick_author='s/^[0-9a-f^]* *(\([^ ]*\) .*/\1/'