]> git.ipfire.org Git - thirdparty/git.git/commit
line-log: fix leak when rewriting commit parents
authorPatrick Steinhardt <ps@pks.im>
Wed, 20 Nov 2024 13:39:37 +0000 (14:39 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:23:42 +0000 (08:23 +0900)
commit141766d1bb801ae2a9c7358920ce8dc9697f53c4
tree0d8c3bfc70bebdf1cfcd5ff7a2483702c4f8174b
parentc1e98f90103e8d98ef441ce8f609cf3bc8fa538b
line-log: fix leak when rewriting commit parents

In `process_ranges_merge_commit()` we try to figure out which of the
parents can be blamed for the given line changes. When we figure out
that none of the files in the line-log have changed we assign the
complete blame to that commit and rewrite the parents of the current
commit to only use that single parent.

This is done via `commit_list_append()`, which is misleadingly _not_
appending to the list of parents. Instead, we overwrite the parents with
the blamed parent. This makes us lose track of the old pointers,
creating a memory leak.

Fix this issue by freeing the parents before we overwrite them.

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