Skip to content

Commit 3ef52dd

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba9d029 commit 3ef52dd

File tree

5 files changed

+6
-0
lines changed

5 files changed

+6
-0
lines changed

submodule-config.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ static void free_one_config(struct submodule_entry *entry)
9191
free((void *) entry->config->path);
9292
free((void *) entry->config->name);
9393
free((void *) entry->config->branch);
94+
free((void *) entry->config->url);
95+
free((void *) entry->config->ignore);
9496
free((void *) entry->config->update_strategy.command);
9597
free(entry->config);
9698
}

t/t1013-read-tree-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='read-tree can handle submodules'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-submodule-update.sh
78

t/t2013-checkout-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='checkout can handle submodules'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-submodule-update.sh
78

t/t3007-ls-files-recurse-submodules.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly lists files from
66
submodules.
77
'
88

9+
TEST_PASSES_SANITIZE_LEAK=true
910
. ./test-lib.sh
1011

1112
test_expect_success 'setup directory structure and submodules' '

t/t7112-reset-submodule.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='reset can handle submodules'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-submodule-update.sh
78

0 commit comments

Comments
 (0)