Skip to content

Commit 272f0a5

Browse files
avargitster
authored andcommitted
ls-files: add missing string_list_clear()
Fix a memory leak that's been here ever since 72aeb18 (clean.c, ls-files.c: respect encapsulation of exclude_list_groups, 2013-01-16), we dup'd the argument in option_parse_exclude(), but never freed the string_list. This makes almost all of t3001-ls-files-others-exclude.sh pass (it had a lot of failures before). Let's mark it as passing with TEST_PASSES_SANITIZE_LEAK=true, and then exclude the tests that still failed with a !SANITIZE_LEAK prerequisite check until we fix those leaks. We can still see the failed tests under GIT_TEST_FAIL_PREREQS=true. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eab4ac6 commit 272f0a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

builtin/ls-files.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
781781
ret = 1;
782782
}
783783

784+
string_list_clear(&exclude_list, 0);
784785
dir_clear(&dir);
785786
free(max_prefix);
786787
return ret;

t/t3001-ls-files-others-exclude.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test_description='git ls-files --others --exclude
88
This test runs git ls-files --others and tests --exclude patterns.
99
'
1010

11+
TEST_PASSES_SANITIZE_LEAK=true
1112
. ./test-lib.sh
1213

1314
rm -fr one three
@@ -102,7 +103,7 @@ test_expect_success \
102103
>output &&
103104
test_cmp expect output'
104105

105-
test_expect_success 'restore gitignore' '
106+
test_expect_success !SANITIZE_LEAK 'restore gitignore' '
106107
git checkout --ignore-skip-worktree-bits $allignores &&
107108
rm .git/index
108109
'
@@ -125,7 +126,7 @@ cat > expect << EOF
125126
# three/
126127
EOF
127128

128-
test_expect_success 'git status honors core.excludesfile' \
129+
test_expect_success !SANITIZE_LEAK 'git status honors core.excludesfile' \
129130
'test_cmp expect output'
130131

131132
test_expect_success 'trailing slash in exclude allows directory match(1)' '

0 commit comments

Comments
 (0)