]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/blame: fix leaking prefixed paths
authorPatrick Steinhardt <ps@pks.im>
Tue, 11 Jun 2024 09:21:25 +0000 (11:21 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 Jun 2024 20:15:08 +0000 (13:15 -0700)
commit3332f35577ccbb51a50d88d16caafcceaab23767
treefc04475a6d497eebc65cfb9a78b7a625892875be
parentee6a998583108cebc0db28d70df2aa1b547b6251
builtin/blame: fix leaking prefixed paths

In `cmd_blame()` we compute prefixed paths by calling `add_prefix()`,
which itself calls `prefix_path()`. While `prefix_path()` returns an
allocated string, `add_prefix()` pretends to return a constant string.
Consequently, this path never gets freed.

Fix the return type to be `char *` and free the path to plug the memory
leak.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/blame.c
t/t6130-pathspec-noglob.sh
t/t7010-setup.sh
t/t8003-blame-corner-cases.sh
t/t8008-blame-formats.sh