Skip to content

Commit 8192c1b

Browse files
avarttaylorr
authored andcommitted
ls-files: fix a --with-tree memory leak
Fix a memory leak in overlay_tree_on_index(), we need to clear_pathspec() at some point, which might as well be after the last time we use it in the function. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent a53cd1b commit 8192c1b

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

builtin/ls-files.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ void overlay_tree_on_index(struct index_state *istate,
613613
if (!fn)
614614
fn = read_one_entry_quick;
615615
err = read_tree(the_repository, tree, &pathspec, fn, istate);
616+
clear_pathspec(&pathspec);
616617
if (err)
617618
die("unable to read tree entries %s", tree_name);
618619

t/t3060-ls-files-with-tree.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ test_description='git ls-files test (--with-tree).
88
This test runs git ls-files --with-tree and in particular in
99
a scenario known to trigger a crash with some versions of git.
1010
'
11+
12+
TEST_PASSES_SANITIZE_LEAK=true
1113
. ./test-lib.sh
1214

1315
test_expect_success 'setup' '

t/t9148-git-svn-propset.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
test_description='git svn propset tests'
77

8-
TEST_FAILS_SANITIZE_LEAK=true
98
. ./lib-git-svn.sh
109

1110
test_expect_success 'setup propset via import' '

0 commit comments

Comments
 (0)