]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/describe: fix leaking array when running diff-index
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2024 10:38:25 +0000 (12:38 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 1 Aug 2024 15:47:35 +0000 (08:47 -0700)
commit5a1e1e5d4055e142369a05a6d71e5101eead8ab2
tree99b9e3875eeb6fc0e1f30bcbafa90ca6850bdccf
parent8e2e28799d2353e32c393bd7938c457e5e08fc63
builtin/describe: fix leaking array when running diff-index

When running git-describe(1) with `--dirty`, we will set up a `struct
rev_info` with arguments for git-diff-index(1). The way we assemble the
arguments it causes two memory leaks though:

  - We never release the `struct strvec`.

  - `setup_revisions()` may end up removing some entries from the
    `strvec`, which we wouldn't free even if we released the struct.

While we could plug those leaks, this is ultimately unnecessary as the
arguments we pass are part of a static array anyway. So instead,
refactor the code to drop the `struct strvec` and just pass this static
array directly.

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