]> git.ipfire.org Git - thirdparty/git.git/commit
apply: fix leaking string in `match_fragment()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:20:52 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:07 +0000 (13:15 -0700)
commit4806c55c86f7cc45f60a7ff5d757874072265deb
tree911fbcb67b1edc0e2de8a98904fc32c561e6f8ce
parent1e5c1601f98afba0772c4548ec6befe6e97761e7
apply: fix leaking string in `match_fragment()`

Before calling `update_pre_post_images()`, we call `strbuf_detach()` to
put its buffer into a new string variable that we then pass to that
function. Besides being rather pointless, it also causes us to leak
memory of that variable because we never free it.

Get rid of the variable altogether and instead reach into the `strbuf`
directly. While at it, refactor the code to have a common exit path and
mark string that do not contain allocated memory as constant.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
t/t3417-rebase-whitespace-fix.sh