Skip to content

Commit dd4143e

Browse files
avargitster
authored andcommitted
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 c6807a4 (clone: open a shortcut for connectivity check, 2013-05-26). Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent f1f4ebf commit dd4143e

8 files changed

+13
-1
lines changed

connected.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
8585
promisor_pack_found:
8686
;
8787
} while ((oid = fn(cb_data)) != NULL);
88+
free(new_pack);
8889
return 0;
8990
}
9091

@@ -118,8 +119,10 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
118119
else
119120
rev_list.no_stderr = opt->quiet;
120121

121-
if (start_command(&rev_list))
122+
if (start_command(&rev_list)) {
123+
free(new_pack);
122124
return error(_("Could not run 'git rev-list'"));
125+
}
123126

124127
sigchain_push(SIGPIPE, SIG_IGN);
125128

@@ -151,5 +154,6 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
151154
err = error_errno(_("failed to close rev-list's stdin"));
152155

153156
sigchain_pop(SIGPIPE);
157+
free(new_pack);
154158
return finish_command(&rev_list) || err;
155159
}

t/t3050-subprojects-fetch.sh

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

33
test_description='fetching and pushing project with subproject'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success setup '

t/t4067-diff-partial-clone.sh

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

33
test_description='behavior of diff when reading objects in a partial clone'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
test_expect_success 'git show batches blobs' '

t/t5544-pack-objects-hook.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='test custom script in place of pack-objects'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'create some history to fetch' '

t/t5610-clone-detached.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='test cloning a repository with detached HEAD'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
head_is_detached() {

t/t5611-clone-config.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='tests for git clone -c key=value'
44
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
55
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
66

7+
TEST_PASSES_SANITIZE_LEAK=true
78
. ./test-lib.sh
89

910
test_expect_success 'clone -c sets config in cloned repo' '

t/t5614-clone-submodules-shallow.sh

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

33
test_description='Test shallow cloning of repos with submodules'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67

78
pwd=$(pwd)

t/t5617-clone-submodules-remote.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ test_description='Test cloning repos with submodules using remote-tracking branc
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
77

8+
TEST_PASSES_SANITIZE_LEAK=true
89
. ./test-lib.sh
910

1011
pwd=$(pwd)

0 commit comments

Comments
 (0)