convert: fix leaks when resetting attributes
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>
Patrick Steinhardt committed
Aug 22, 2024 at 11:17 UTC
643c6f576cb7b0a7e2345cd4f8e8d7468fefc483
2 files changed
+4
convert.c
+3
@@ -1371,6 +1371,9 @@ void reset_parsed_attributes(void)
1371
for (drv = user_convert; drv; drv = next) {
1372
next = drv->next;
1373
free((void *)drv->name);
1374
+ free((void *)drv->smudge);
1375
+ free((void *)drv->clean);
1376
+ free((void *)drv->process);
1377
free(drv);
1378
}
1379
user_convert = NULL;
t/t4150-am.sh
+1
@@ -5,6 +5,7 @@ test_description='git am running'
5
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8
+TEST_PASSES_SANITIZE_LEAK=true
9
. ./test-lib.sh
10
11
test_expect_success 'setup: messages' '