]> git.ipfire.org Git - thirdparty/git.git/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 33586b97772c2b699ea0aa555a4d6501c1681b70..f97d0e9e1a1e0a899728baa0e596ba3f54de3ee8 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 7750b87ca16ab39aa965caa4fe71b462d899adc7..2942e5d9b93899bf7bc517e95c94788dbca1d18f 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 0147de304b4d104cc7f05ea1f8d68f1a07ceb80d..35966340397591eee54a0f82d00eed70b3814e98 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 35414a53363424190e57a553302c6384e3664e2c..2c2a0b33f9bad5838ea14ebb908a0c1d066f2b4a 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 7683515155497d9303f319b31c3a49fb6610706f..42f8be25a3fdf98c0e1fc221fe8a43b8c103b69c 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 72596e38b25f65fc52da2a94cf0f453636e8f66c..30331713b950a5bb83af61f5e786325dd523801b 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 bdda0c03fe9ea6fc536fb2711051fed066d7c421..da1801f4d23edaf15b156d72ab8c98b40fdc3cea 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 c3a5f6d01ffe5cff12b868e7cbe5a09dacbef011..9a79c109f2e9853158f2efaa64880c4f93b53d88 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 0bd034130189db8561d824449de646f2bfcef61f..933222cea15073411977b47fa343e2e221870c07 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/'