]> git.ipfire.org Git - thirdparty/git.git/commit
userdiff: fix leaking memory for configured diff drivers
authorPatrick Steinhardt <ps@pks.im>
Wed, 14 Aug 2024 06:52:50 +0000 (08:52 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Aug 2024 17:08:01 +0000 (10:08 -0700)
commit38678e5df55b77e98b47e7847faf83451eb161de
tree53a018a71f6eb23f5bfe88a0494ae635caa807a6
parent1bc158e7509851d9cb007273c9f75a238f295d2e
userdiff: fix leaking memory for configured diff drivers

The userdiff structures may be initialized either statically on the
stack or dynamically via configuration keys. In the latter case we end
up leaking memory because we didn't have any infrastructure to discern
those strings which have been allocated statically and those which have
been allocated dynamically.

Refactor the code such that we have two pointers for each of these
strings: one that holds the value as accessed by other subsystems, and
one that points to the same string in case it has been allocated. Like
this, we can safely free the second pointer and thus plug those memory
leaks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
range-diff.c
t/t4018-diff-funcname.sh
t/t4042-diff-textconv-caching.sh
t/t4048-diff-combined-binary.sh
t/t4209-log-pickaxe.sh
userdiff.c
userdiff.h