]> git.ipfire.org Git - thirdparty/git.git/commit
git: fix leaking argv when handling builtins
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:06 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:34 +0000 (08:25 -0700)
commit3aef7a05adb2868118181eb5605fffa65a9af2c8
tree25fd341033495e60ba383ad7f327864a60056ccd
parent0f26223b6de6ac3a2e514bb306fef29f34970465
git: fix leaking argv when handling builtins

In `handle_builtin()` we may end up creating an ad-hoc argv array in
case we see that the command line contains the "--help" parameter. In
this case we observe two memory leaks though:

  - We leak the `struct strvec` itself because we directly exit after
    calling `run_builtin()`, without bothering about any cleanups.

  - Even if we free'd that vector we'd end up leaking some of its
    strings because `run_builtin()` will modify the array.

Plug both of these leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git.c
t/t0012-help.sh