submodule: fix leaking memory for submodule entries
In `free_one_config()` we never end up freeing the `url` and `ignore` fields and thus leak memory. Fix those leaks and mark now-passing tests as leak free. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
May 27, 2024 at 13:46 UTC
3ef52dd1125b6c9223fd03aca146f6b799e014f9
5 files changed
+6
submodule-config.c
+2
@@ -91,6 +91,8 @@ static void free_one_config(struct submodule_entry *entry)
91
free((void *) entry->config->path);
92
free((void *) entry->config->name);
93
free((void *) entry->config->branch);
94
+ free((void *) entry->config->url);
95
+ free((void *) entry->config->ignore);
96
free((void *) entry->config->update_strategy.command);
97
free(entry->config);
98
}
t/t1013-read-tree-submodule.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='read-tree can handle submodules'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
. "$TEST_DIRECTORY"/lib-submodule-update.sh
8
t/t2013-checkout-submodule.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='checkout can handle submodules'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
. "$TEST_DIRECTORY"/lib-submodule-update.sh
8
t/t3007-ls-files-recurse-submodules.sh
+1
@@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly lists files from
6
submodules.
7
'
8
9
+TEST_PASSES_SANITIZE_LEAK=true
10
. ./test-lib.sh
11
12
test_expect_success 'setup directory structure and submodules' '
t/t7112-reset-submodule.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='reset can handle submodules'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
. "$TEST_DIRECTORY"/lib-submodule-update.sh
8