Skip to content

Commit e326e52

Browse files
committed
Merge branch 'rj/add-i-leak-fix'
Leakfix. * rj/add-i-leak-fix: add: plug a leak on interactive_add add-patch: plug a leak handling the '/' command add-interactive: plug a leak in get_untracked_files apply: plug a leak in apply_data
2 parents c9d1ee7 + 1672740 commit e326e52

14 files changed

+23
-4
lines changed

add-interactive.c

+1
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,7 @@ static int get_untracked_files(struct repository *r,
865865
}
866866

867867
strbuf_release(&buf);
868+
dir_clear(&dir);
868869
return 0;
869870
}
870871

add-patch.c

+1
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,7 @@ static int patch_update_file(struct add_p_state *s,
16461646
err(s, _("No hunk matches the given pattern"));
16471647
break;
16481648
}
1649+
regfree(&regex);
16491650
hunk_index = i;
16501651
} else if (s->answer.buf[0] == 's') {
16511652
size_t splittable_into = hunk->splittable_into;

apply.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -3712,8 +3712,10 @@ static int apply_data(struct apply_state *state, struct patch *patch,
37123712
fprintf(stderr, _("Falling back to direct application...\n"));
37133713

37143714
/* Note: with --reject, apply_fragments() returns 0 */
3715-
if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0)
3715+
if (patch->direct_to_threeway || apply_fragments(state, &image, patch) < 0) {
3716+
clear_image(&image);
37163717
return -1;
3718+
}
37173719
}
37183720
patch->result = image.buf;
37193721
patch->resultsize = image.len;

builtin/add.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static int refresh(int verbose, const struct pathspec *pathspec)
150150
int interactive_add(const char **argv, const char *prefix, int patch)
151151
{
152152
struct pathspec pathspec;
153-
int unused;
153+
int unused, ret;
154154

155155
if (!git_config_get_bool("add.interactive.usebuiltin", &unused))
156156
warning(_("the add.interactive.useBuiltin setting has been removed!\n"
@@ -163,9 +163,12 @@ int interactive_add(const char **argv, const char *prefix, int patch)
163163
prefix, argv);
164164

165165
if (patch)
166-
return !!run_add_p(the_repository, ADD_P_ADD, NULL, &pathspec);
166+
ret = !!run_add_p(the_repository, ADD_P_ADD, NULL, &pathspec);
167167
else
168-
return !!run_add_i(the_repository, &pathspec);
168+
ret = !!run_add_i(the_repository, &pathspec);
169+
170+
clear_pathspec(&pathspec);
171+
return ret;
169172
}
170173

171174
static int edit_patch(int argc, const char **argv, const char *prefix)

t/t2016-checkout-patch.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='git checkout --patch'
44

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

78
test_expect_success 'setup' '

t/t3701-add-interactive.sh

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ test_description='add -i basic tests'
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
. "$TEST_DIRECTORY"/lib-terminal.sh
910

t/t4103-apply-binary.sh

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ test_description='git apply handling binary patches
99
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
1010
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1111

12+
TEST_PASSES_SANITIZE_LEAK=true
1213
. ./test-lib.sh
1314

1415
test_expect_success 'setup' '

t/t4104-apply-boundary.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
test_description='git apply boundary tests'
77

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

1011
L="c d e f g h i j k l m n o p q r s t u v w x"

t/t4113-apply-ending.sh

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
test_description='git apply trying to add an ending line.
77
88
'
9+
TEST_PASSES_SANITIZE_LEAK=true
910
. ./test-lib.sh
1011

1112
# setup

t/t4117-apply-reject.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ test_description='git apply with rejects
77
88
'
99

10+
TEST_PASSES_SANITIZE_LEAK=true
1011
. ./test-lib.sh
1112

1213
test_expect_success setup '

t/t4123-apply-shrink.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='apply a patch that is larger than the preimage'
44

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

78
cat >F <<\EOF

t/t4252-am-options.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='git am with options and not losing them'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
tm="$TEST_DIRECTORY/t4252"

t/t4258-am-quoted-cr.sh

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
test_description='test am --quoted-cr=<action>'
44

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

78
DATA="$TEST_DIRECTORY/t4258"

t/t7514-commit-patch.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/sh
22

33
test_description='hunk edit with "commit -p -m"'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup (initial)' '

0 commit comments

Comments
 (0)