]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule: fix leaking memory for submodule entries
authorPatrick Steinhardt <ps@pks.im>
Mon, 27 May 2024 11:46:59 +0000 (13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 May 2024 18:20:01 +0000 (11:20 -0700)
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>
submodule-config.c
t/t1013-read-tree-submodule.sh
t/t2013-checkout-submodule.sh
t/t3007-ls-files-recurse-submodules.sh
t/t7112-reset-submodule.sh

index 11428b4adad515a9e0ee495c16e1af5636dc6546..ec45ea67b95618d4ec626e80af145a5282e0ac0d 100644 (file)
@@ -91,6 +91,8 @@ static void free_one_config(struct submodule_entry *entry)
        free((void *) entry->config->path);
        free((void *) entry->config->name);
        free((void *) entry->config->branch);
+       free((void *) entry->config->url);
+       free((void *) entry->config->ignore);
        free((void *) entry->config->update_strategy.command);
        free(entry->config);
 }
index bfc90d4cf272e8a8d6b6d517787bed0f074f4e82..cf8b94ebedbdd2ce780550d6217e7223bcf20d8b 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='read-tree can handle submodules'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-submodule-update.sh
 
index b2bdd1fcb425a14a12df9fe896269e5f9c349434..3c1d663d948490901fb3de330b35ae0227730158 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='checkout can handle submodules'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-submodule-update.sh
 
index 61771eec830c0688587588ee0a334282effdb1bb..f04bdc8c78b6e852d04ab4b93446248e40459f13 100755 (executable)
@@ -6,6 +6,7 @@ This test verifies the recurse-submodules feature correctly lists files from
 submodules.
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup directory structure and submodules' '
index a3e2413bc339533ef09a9092b2918b7265645e68..b0d3d93b0b48b15d2ad70d2ea833837a27702b9a 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='reset can handle submodules'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 . "$TEST_DIRECTORY"/lib-submodule-update.sh