Skip to content

Commit

Permalink
Merge branch 'rj/leakfixes' into next
Browse files Browse the repository at this point in the history
Leakfixes

* rj/leakfixes:
  tests: mark as passing with SANITIZE=leak
  config: fix a leak in git_config_copy_or_rename_section_in_file
  branch: fix a leak in cmd_branch
  branch: fix a leak in setup_tracking
  rev-parse: fix a leak with --abbrev-ref
  • Loading branch information
gitster committed Jun 18, 2023
2 parents bfc01bd + 80d32e8 commit 49e54a8
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,
if (!skip_prefix(tracking.srcs->items[0].string,
"refs/heads/", &tracked_branch) ||
strcmp(tracked_branch, new_ref))
return;
goto cleanup;
}

if (tracking.srcs->nr < 1)
Expand Down
2 changes: 2 additions & 0 deletions builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
if (list)
setup_auto_pager("branch", 1);

UNLEAK(sorting_options);

if (delete) {
if (!argc)
die(_("branch name required"));
Expand Down
5 changes: 4 additions & 1 deletion builtin/rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ static void show_rev(int type, const struct object_id *oid, const char *name)
*/
break;
case 1: /* happy */
if (abbrev_ref)
if (abbrev_ref) {
char *old = full;
full = shorten_unambiguous_ref(full,
abbrev_ref_strict);
free(old);
}
show_with_type(type, full);
break;
default: /* ambiguous */
Expand Down
1 change: 1 addition & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3844,6 +3844,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
output[0] = '\t';
}
} else {
strbuf_release(&copystr);
copystr = store_create_section(new_name, &store);
}
}
Expand Down
1 change: 1 addition & 0 deletions t/t1507-rev-parse-upstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_description='test <branch>@{upstream} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh


Expand Down
1 change: 1 addition & 0 deletions t/t1508-at-combinations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test_description='test various @{X} syntax combinations together'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

check() {
Expand Down
1 change: 1 addition & 0 deletions t/t1514-rev-parse-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test_description='test <branch>@{push} syntax'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

resolve () {
Expand Down
1 change: 1 addition & 0 deletions t/t2027-checkout-track.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_description='tests for git branch --track'
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 'setup' '
Expand Down
1 change: 1 addition & 0 deletions t/t3200-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ test_description='git branch assorted tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh

Expand Down
1 change: 1 addition & 0 deletions t/t3204-branch-name-interpretation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This script aims to check the behavior of those corner cases.
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

expect_branch() {
Expand Down
1 change: 1 addition & 0 deletions t/t5404-tracking-branches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_description='tracking branch update checks for git push'
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 'setup' '
Expand Down
1 change: 1 addition & 0 deletions t/t5517-push-mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_description='pushing to a mirror repository'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

D=$(pwd)
Expand Down
1 change: 1 addition & 0 deletions t/t5525-fetch-tagopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

test_description='tagopt variable affects "git fetch" and is overridden by commandline.'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

setup_clone () {
Expand Down
1 change: 1 addition & 0 deletions t/t6040-tracking-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ test_description='remote tracking stats'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

advance () {
Expand Down
1 change: 1 addition & 0 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

test_description='git status'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-terminal.sh

Expand Down

0 comments on commit 49e54a8

Please sign in to comment.