]> git.ipfire.org Git - thirdparty/git.git/commit
shell: fix leaking strings
authorPatrick Steinhardt <ps@pks.im>
Mon, 30 Sep 2024 09:13:22 +0000 (11:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 30 Sep 2024 18:23:03 +0000 (11:23 -0700)
commitc75841687b39f4c62fba56bde08653591b9c2149
treef9fb0584efac869663a06c1accf4db7aeae6da39
parentd607bd88161d1826adc236bf7cf758e754becd61
shell: fix leaking strings

There are two memory leaks in "shell.c". The first one in `run_shell()`
is trivial and fixed without further explanation. The second one in
`cmd_main()` happens because we overwrite the `prog` variable, which
contains an allocated string. In fact though, the memory pointed to by
that variable is still in use because we use `split_cmdline()`, which
may create pointers into the middle of that string. But as we do not
have a direct pointer to the head of the allocated string anymore, we
get a complaint by the leak checker.

Address this by not overwriting the `prog` pointer.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
shell.c
t/t9400-git-cvsserver-server.sh
t/t9850-shell.sh