]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/sparse-checkout: fix leaking sanitized patterns
authorPatrick Steinhardt <ps@pks.im>
Wed, 20 Nov 2024 13:39:42 +0000 (14:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:23:43 +0000 (08:23 +0900)
commit58e7568c619cce872b17987f0d14b3de3703129a
tree36ffbfd95bcc4542e3a1ae3b8c725dcc210377af
parenta5408d1820e0ea75612bbd6f6a6c495066e5ffcb
builtin/sparse-checkout: fix leaking sanitized patterns

Both `git sparse-checkout add` and `git sparse-checkout set` accept a
list of additional directories or patterns. These get massaged via calls
to `sanitize_paths()`, which may end up modifying the passed-in array by
updating its pointers to be prefixed paths. This allocates memory that
we never free.

Refactor the code to instead use a `struct strvec`, which makes it way
easier for us to track the lifetime correctly. The couple of extra
memory allocations likely do not matter as we only ever populate it with
command line arguments.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c