]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/ls-remote: fix leaking `pattern` strings
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2024 10:40:02 +0000 (12:40 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2024 15:47:36 +0000 (08:47 -0700)
commit4119fc08e2ed5611c21de9162b3ab61ef0014ada
tree9eaf2e72524fb875ece036cb061b9b574248f4a1
parent6771e2012e15ed3748997566640c34b492c2cf67
builtin/ls-remote: fix leaking `pattern` strings

Users can pass patterns to git-ls-remote(1), which allows them to filter
the list of printed references. We assemble those patterns into an array
and prefix them with "*/", but never free either the array nor the
allocated strings.

Refactor the code to use a `struct strvec` instead of manually tracking
the strings in an array. Like this, we can easily use `strvec_clear()`
to release both the vector and the contained string for us, plugging the
leak.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/ls-remote.c
t/t5535-fetch-push-symref.sh