connected.c: free the "struct packed_git"
The "new_pack" we allocate in check_connected() wasn't being free'd. Let's do that before we return from the function. This has leaked ever since "new_pack" was added to this function in c6807a40dcd (clone: open a shortcut for connectivity check, 2013-05-26). Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Ævar Arnfjörð Bjarmason committed
Nov 8, 2022 at 19:17 UTC
dd4143e7bf406a5907ef86c50c77c4667f62375d
8 files changed
+13
-1
connected.c
+5
-1
@@ -85,6 +85,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
85
promisor_pack_found:
86
;
87
} while ((oid = fn(cb_data)) != NULL);
88
+ free(new_pack);
89
return 0;
90
}
91
@@ -118,8 +119,10 @@ no_promisor_pack_found:
119
else
120
rev_list.no_stderr = opt->quiet;
121
121
- if (start_command(&rev_list))
122
+ if (start_command(&rev_list)) {
123
+ free(new_pack);
124
return error(_("Could not run 'git rev-list'"));
125
+ }
126
127
sigchain_push(SIGPIPE, SIG_IGN);
128
@@ -151,5 +154,6 @@ no_promisor_pack_found:
154
err = error_errno(_("failed to close rev-list's stdin"));
155
156
sigchain_pop(SIGPIPE);
157
+ free(new_pack);
158
return finish_command(&rev_list) || err;
159
}
t/t3050-subprojects-fetch.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='fetching and pushing project with subproject'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_expect_success setup '
t/t4067-diff-partial-clone.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='behavior of diff when reading objects in a partial clone'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_expect_success 'git show batches blobs' '
t/t5544-pack-objects-hook.sh
+2
@@ -1,6 +1,8 @@
1
#!/bin/sh
2
3
test_description='test custom script in place of pack-objects'
4
+
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
test_expect_success 'create some history to fetch' '
t/t5610-clone-detached.sh
+1
@@ -4,6 +4,7 @@ test_description='test cloning a repository with detached HEAD'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_PASSES_SANITIZE_LEAK=true
8
. ./test-lib.sh
9
10
head_is_detached() {
t/t5611-clone-config.sh
+1
@@ -4,6 +4,7 @@ test_description='tests for git clone -c key=value'
4
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
7
+TEST_PASSES_SANITIZE_LEAK=true
8
. ./test-lib.sh
9
10
test_expect_success 'clone -c sets config in cloned repo' '
t/t5614-clone-submodules-shallow.sh
+1
@@ -2,6 +2,7 @@
2
3
test_description='Test shallow cloning of repos with submodules'
4
5
+TEST_PASSES_SANITIZE_LEAK=true
6
. ./test-lib.sh
7
8
pwd=$(pwd)
t/t5617-clone-submodules-remote.sh
+1
@@ -5,6 +5,7 @@ test_description='Test cloning repos with submodules using remote-tracking branc
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
pwd=$(pwd)