]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/merge-recursive: fix leaking object ID bases
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:20:09 +0000 (11:20 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:06 +0000 (13:15 -0700)
commit3199b22e7d8cf8a95b7fac4e4aaf65638256b226
tree07979b04cb6473442278afad4a84aacb60ee4b1a
parent9e903a5531f239a1ff3ab5fec2f0bb6fda595010
builtin/merge-recursive: fix leaking object ID bases

In `cmd_merge_recursive()` we have a static array of object ID bases
that we pass to `merge_recursive_generic()`. This interface is somewhat
weird though because the latter function accepts a pointer to a pointer
of object IDs, which requires us to allocate the object IDs on the heap.
And as we never free those object IDs, the end result is a leak.

While we can easily solve this leak by just freeing the respective
object IDs, the whole calling convention is somewhat weird. Instead,
refactor `merge_recursive_generic()` to accept a plain pointer to object
IDs so that we can avoid allocating them altogether.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
builtin/merge-recursive.c
merge-recursive.c
merge-recursive.h
t/t6432-merge-recursive-space-options.sh
t/t6434-merge-recursive-rename-options.sh