]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/maintenance: fix leak in `get_schedule_cmd()`
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:47:02 +0000 (13:47 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:37 +0000 (08:25 -0700)
commitb6c3f8e12c0a521450923ddbcf7a19a81aa3c4e7
treed91bfec01734dda3b5ca03d861678d9cd043e043
parent84e9fc361dca294629ef0b1e4e2eea815fc5b522
builtin/maintenance: fix leak in `get_schedule_cmd()`

The `get_schedule_cmd()` function allows us to override the schedule
command with a specific test command such that we can verify the
underlying logic in a platform-independent way. Its memory management is
somewhat wild though, because it basically gives up and assigns an
allocated string to the string constant output pointer. While this part
is marked with `UNLEAK()` to mask this, we also leak the local string
lists.

Rework the function such that it has a separate out parameter. If set,
we will assign it the final allocated command. Plug the other memory
leaks and create a common exit path.

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