]> Kevux Git Server - rit/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 e6184d2..c9a31eb 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 5e2b6c8..232e139 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' '