diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2023-02-07 02:07:43 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-02-07 02:34:38 +0300 |
commit | 9f24f3c719ccb4553f97a861c37cbedcc7357762 (patch) | |
tree | 6539f045cfd6ee814ab92a03e68af8999c13eba4 /t/t2406-worktree-repair.sh | |
parent | 90428ddccf7bc0c0c192fc973b2d1a7a47605e10 (diff) |
worktree: fix a trivial leak in prune_worktrees()
We were leaking both the "struct strbuf" in prune_worktrees(), as well
as the "path" we got from should_prune_worktree(). Since these were
the only two uses of the "struct string_list" let's change it to a
"DUP" and push these to it with "string_list_append_nodup()".
For the string_list_append_nodup() we could also string_list_append()
the main_path.buf, and then strbuf_release(&main_path) right away. But
doing it this way avoids an allocation, as we already have the "struct
strbuf" prepared for appending to "kept".
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t2406-worktree-repair.sh')
-rwxr-xr-x | t/t2406-worktree-repair.sh | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/t/t2406-worktree-repair.sh b/t/t2406-worktree-repair.sh index 5c44453e1c..8970780efc 100755 --- a/t/t2406-worktree-repair.sh +++ b/t/t2406-worktree-repair.sh @@ -2,6 +2,7 @@ test_description='test git worktree repair' +TEST_PASSES_SANITIZE_LEAK=true . ./test-lib.sh test_expect_success setup ' |