]> git.ipfire.org Git - thirdparty/git.git/commit
mailinfo: fix leaking header data
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:17:11 +0000 (11:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:03 +0000 (09:18 -0700)
commite5530f9c5c011125420bb6416f9ba519082e98b6
tree6a897bcaac547d1eac0f462c425a55642a4bf25c
parent2df380c2800b319be2587e301a82cc23656294e2
mailinfo: fix leaking header data

We populate the `mailinfo` arrays `p_hdr_data` and `s_hdr_data` with
data parsed from the mail headers. These arrays may end up being only
partially populated with gaps in case some of the headers do not parse
properly. This causes memory leaks because `strbuf_list_free()` will
stop iterating once it hits the first `NULL` pointer in the backing
array.

Fix this by open-coding a variant of `strbuf_list_free()` that knows to
iterate through all headers.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
mailinfo.c
t/t5100-mailinfo.sh