]> git.ipfire.org Git - thirdparty/git.git/commitdiff
add-interactive: plug a leak in get_untracked_files
authorRubén Justo <rjusto@gmail.com>
Mon, 22 Apr 2024 22:54:08 +0000 (00:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 22 Apr 2024 23:27:42 +0000 (16:27 -0700)
Plug a leak we have since ab1e1cccaf (built-in add -i: re-implement
`add-untracked` in C, 2019-11-29).

This leak can be triggered with:

$ echo a | git add -i

As a curiosity, we have a somewhat similar function in builtin/stash.c,
which correctly frees the memory.

Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
add-interactive.c

index 6bf87e7ae71b06ea59d42d238c6242a66fdec0b5..e17602b5e415d0f6fd0f96b9b012303751d3cbcb 100644 (file)
@@ -865,6 +865,7 @@ static int get_untracked_files(struct repository *r,
        }
 
        strbuf_release(&buf);
+       dir_clear(&dir);
        return 0;
 }