]> git.ipfire.org Git - thirdparty/git.git/commitdiff
convert: fix leaks when resetting attributes
authorPatrick Steinhardt <ps@pks.im>
Thu, 22 Aug 2024 09:17:13 +0000 (11:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Aug 2024 16:18:03 +0000 (09:18 -0700)
When resetting parsed gitattributes, we free the list of convert drivers
parsed from the config. We only free some of the drivers' fields though
and thus have memory leaks.

Fix this by freeing all allocated convert driver fields to plug these
memory leaks.

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

index e6184d21f266f708154a4035dd369919619102f5..c9a31eb4f03d6caa7bedba4b5237c42344f304c5 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1371,6 +1371,9 @@ void reset_parsed_attributes(void)
        for (drv = user_convert; drv; drv = next) {
                next = drv->next;
                free((void *)drv->name);
+               free((void *)drv->smudge);
+               free((void *)drv->clean);
+               free((void *)drv->process);
                free(drv);
        }
        user_convert = NULL;
index 5e2b6c80eaedfcbc1600a24c425dd4127233ff32..232e1394e8d9259dae68b80e619597d5176ff11b 100755 (executable)
@@ -5,6 +5,7 @@ test_description='git am running'
 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup: messages' '