Skip to content

Commit ee3e8c3

Browse files
pks-tgitster
authored andcommitted
t/helper: fix leaks in "reach" test tool
The "reach" test tool doesn't bother to clean up any of its allocated resources, causing various leaks. Plug them. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f5dd8e commit ee3e8c3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

t/helper/test-reach.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,12 @@ int cmd__reach(int ac, const char **av)
127127
exit(128);
128128
printf("%s(A,X):\n", av[1]);
129129
print_sorted_commit_ids(list);
130+
free_commit_list(list);
130131
} else if (!strcmp(av[1], "reduce_heads")) {
131132
struct commit_list *list = reduce_heads(X);
132133
printf("%s(X):\n", av[1]);
133134
print_sorted_commit_ids(list);
135+
free_commit_list(list);
134136
} else if (!strcmp(av[1], "can_all_from_reach")) {
135137
printf("%s(X,Y):%d\n", av[1], can_all_from_reach(X, Y, 1));
136138
} else if (!strcmp(av[1], "can_all_from_reach_with_flag")) {
@@ -153,6 +155,7 @@ int cmd__reach(int ac, const char **av)
153155
filter.with_commit_tag_algo = 0;
154156

155157
printf("%s(_,A,X,_):%d\n", av[1], commit_contains(&filter, A, X, &cache));
158+
clear_contains_cache(&cache);
156159
} else if (!strcmp(av[1], "get_reachable_subset")) {
157160
const int reachable_flag = 1;
158161
int i, count = 0;
@@ -176,7 +179,14 @@ int cmd__reach(int ac, const char **av)
176179
die(_("too many commits marked reachable"));
177180

178181
print_sorted_commit_ids(list);
182+
free_commit_list(list);
179183
}
180184

185+
object_array_clear(&X_obj);
186+
strbuf_release(&buf);
187+
free_commit_list(X);
188+
free_commit_list(Y);
189+
free(X_array);
190+
free(Y_array);
181191
return 0;
182192
}

t/t6600-test-reach.sh

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

33
test_description='basic commit reachability tests'
44

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

78
# Construct a grid-like commit graph with points (x,y)

0 commit comments

Comments
 (0)