]> git.ipfire.org Git - thirdparty/git.git/commit
wt-status: fix leaking buffer with sparse directories
authorPatrick Steinhardt <ps@pks.im>
Mon, 30 Sep 2024 09:13:24 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2024 18:23:03 +0000 (11:23 -0700)
commit666643fa89e4386c0f4eabd1112e8b3af0cb9cc1
tree4bae05b501fa4eed53e7641520a2cef439923e1d
parentc75841687b39f4c62fba56bde08653591b9c2149
wt-status: fix leaking buffer with sparse directories

When hitting a sparse directory in `wt_status_collect_changes_initial()`
we use a `struct strbuf` to assemble the directory's name. We never free
that buffer though, causing a memory leak.

Fix the leak by releasing the buffer. While at it, move the buffer
outside of the loop and reset it to save on some wasteful allocations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1092-sparse-checkout-compatibility.sh
wt-status.c