]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ls-files: fix a --with-tree memory leak
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 8 Nov 2022 18:17:45 +0000 (19:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Nov 2022 03:32:48 +0000 (12:32 +0900)
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 <avarab@gmail.com>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
builtin/ls-files.c
t/t3060-ls-files-with-tree.sh
t/t9148-git-svn-propset.sh

index 4cf8a2364835c9fc1ae39b8d52fd09a8aeeb368e..a03b559ecaab4caeba9a9a18bb268f22274e7b2a 100644 (file)
@@ -613,6 +613,7 @@ void overlay_tree_on_index(struct index_state *istate,
        if (!fn)
                fn = read_one_entry_quick;
        err = read_tree(the_repository, tree, &pathspec, fn, istate);
+       clear_pathspec(&pathspec);
        if (err)
                die("unable to read tree entries %s", tree_name);
 
index 52f76f7b57f3ba9861bc9220602a5ca9fc45aeea..c4a72ae44623a0bab3ce06c1a5e850e9e8405054 100755 (executable)
@@ -8,6 +8,8 @@ test_description='git ls-files test (--with-tree).
 This test runs git ls-files --with-tree and in particular in
 a scenario known to trigger a crash with some versions of git.
 '
+
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
index 6cc76a07b39a90d590759bbb7033da3953969092..aebb28995e50a0a589e8fff33997d9816de1fdb2 100755 (executable)
@@ -5,7 +5,6 @@
 
 test_description='git svn propset tests'
 
-TEST_FAILS_SANITIZE_LEAK=true
 . ./lib-git-svn.sh
 
 test_expect_success 'setup propset via import' '