]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: free some "displaypath" in "struct update_data"
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 31 Aug 2022 23:14:22 +0000 (01:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:18:13 +0000 (09:18 -0700)
Make the update_data_release() function free "displaypath" member when
appropriate. The "displaypath" member is always ours, the "const" on
the "char *" was wrong to begin with.

This leaves a leak of "displaypath" in update_submodule(), which as
we'll see in subsequent commits is harder to deal with than this
trivial fix.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Reviewed-by: Glen Choo <chooglen@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
t/t2403-worktree-move.sh
t/t7412-submodule-absorbgitdirs.sh
t/t7419-submodule-set-branch.sh

index 23c4f8d5767e3539ee39b3735c23a32b70fc3d1f..cc32eb0dc3d73b71728a4189022a16f9d71218fa 100644 (file)
@@ -1877,7 +1877,7 @@ static void submodule_update_clone_release(struct submodule_update_clone *suc)
 
 struct update_data {
        const char *prefix;
-       const char *displaypath;
+       char *displaypath;
        enum submodule_update_type update_default;
        struct object_id suboid;
        struct string_list references;
@@ -1915,6 +1915,7 @@ struct update_data {
 
 static void update_data_release(struct update_data *ud)
 {
+       free(ud->displaypath);
        module_list_release(&ud->list);
 }
 
index a4e1a178e0a00335affa95d566728e3085804b47..1168e9f998232ccfa3d4c7c2e875b95299f23ead 100755 (executable)
@@ -2,6 +2,7 @@
 
 test_description='test git worktree move, remove, lock and unlock'
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup' '
index 1cfa150768d7f813ba9943b4bd17887469cb1c04..2859695c6d208341f5ba1de01e1cfe4131388a2b 100755 (executable)
@@ -6,6 +6,7 @@ This test verifies that `git submodue absorbgitdirs` moves a submodules git
 directory into the superproject.
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 . ./test-lib.sh
 
 test_expect_success 'setup a real submodule' '
index 3b925c302fc4e2194a2e0ad10c0b48823f2cf021..96e984232144c60743d59150c68461e5b1e779eb 100755 (executable)
@@ -9,6 +9,7 @@ This test verifies that the set-branch subcommand of git-submodule is working
 as expected.
 '
 
+TEST_PASSES_SANITIZE_LEAK=true
 TEST_NO_CREATE_REPO=1
 . ./test-lib.sh