1
0
mirror of https://github.com/git/git synced 2024-07-02 15:48:44 +00:00

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
c6807a40dc (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>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-11-08 19:17:47 +01:00 committed by Junio C Hamano
parent f1f4ebf432
commit dd4143e7bf
8 changed files with 13 additions and 1 deletions

View File

@ -85,6 +85,7 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
promisor_pack_found:
;
} while ((oid = fn(cb_data)) != NULL);
free(new_pack);
return 0;
}
@ -118,8 +119,10 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
else
rev_list.no_stderr = opt->quiet;
if (start_command(&rev_list))
if (start_command(&rev_list)) {
free(new_pack);
return error(_("Could not run 'git rev-list'"));
}
sigchain_push(SIGPIPE, SIG_IGN);
@ -151,5 +154,6 @@ int check_connected(oid_iterate_fn fn, void *cb_data,
err = error_errno(_("failed to close rev-list's stdin"));
sigchain_pop(SIGPIPE);
free(new_pack);
return finish_command(&rev_list) || err;
}

View File

@ -2,6 +2,7 @@
test_description='fetching and pushing project with subproject'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,6 +2,7 @@
test_description='behavior of diff when reading objects in a partial clone'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'git show batches blobs' '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='test custom script in place of pack-objects'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'create some history to fetch' '

View File

@ -4,6 +4,7 @@ test_description='test cloning a repository with detached HEAD'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
head_is_detached() {

View File

@ -4,6 +4,7 @@ test_description='tests for git clone -c key=value'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'clone -c sets config in cloned repo' '

View File

@ -2,6 +2,7 @@
test_description='Test shallow cloning of repos with submodules'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
pwd=$(pwd)

View File

@ -5,6 +5,7 @@ test_description='Test cloning repos with submodules using remote-tracking branc
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
pwd=$(pwd)