]> git.ipfire.org Git - thirdparty/git.git/commit
pseudo-merge: fix leaking strmap keys
authorPatrick Steinhardt <ps@pks.im>
Mon, 30 Sep 2024 09:13:53 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2024 18:23:06 +0000 (11:23 -0700)
commitd0ab6630a710c8b3f4cf7e1a3f630a685c5d5721
tree9385fc2c5f0b9f8a0700706ac67038464928aa93
parent55e563a90cabacd144b529b8bab7c4bb1cecbc49
pseudo-merge: fix leaking strmap keys

When creating a new pseudo-merge group we collect a set of matchnig
commits and put them into a string map. This strmap is initialized such
that it does not allocate its keys, and instead we try to pass ownership
of the keys to it via `strmap_put()`. This isn't how it works though:
the strmap will never try to release these keys, and consequently they
end up leaking.

Fix this leak by initializing the strmap as duplicating its keys and not
trying to hand over ownership.

The leak is exposed by t5333, but plugging it does not yet make the full
test suite pass.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pseudo-merge.c