Skip to content

Commit 54c4f8c

Browse files
committed
Merge branch 'ab/mark-leak-free-tests-more'
Bunch of tests are marked as "passing leak check". * ab/mark-leak-free-tests-more: merge: add missing strbuf_release() ls-files: add missing string_list_clear() ls-files: fix a trivial dir_clear() leak tests: fix test-oid-array leak, test in SANITIZE=leak tests: fix a memory leak in test-oidtree.c tests: fix a memory leak in test-parse-options.c tests: fix a memory leak in test-prio-queue.c
2 parents 5a4f838 + 465028e commit 54c4f8c

16 files changed

+38
-11
lines changed

builtin/ls-files.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
672672
N_("suppress duplicate entries")),
673673
OPT_END()
674674
};
675+
int ret = 0;
675676

676677
if (argc == 2 && !strcmp(argv[1], "-h"))
677678
usage_with_options(ls_files_usage, builtin_ls_files_options);
@@ -775,16 +776,13 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
775776
if (show_resolve_undo)
776777
show_ru_info(the_repository->index);
777778

778-
if (ps_matched) {
779-
int bad;
780-
bad = report_path_error(ps_matched, &pathspec);
781-
if (bad)
782-
fprintf(stderr, "Did you forget to 'git add'?\n");
783-
784-
return bad ? 1 : 0;
779+
if (ps_matched && report_path_error(ps_matched, &pathspec)) {
780+
fprintf(stderr, "Did you forget to 'git add'?\n");
781+
ret = 1;
785782
}
786783

784+
string_list_clear(&exclude_list, 0);
787785
dir_clear(&dir);
788786
free(max_prefix);
789-
return 0;
787+
return ret;
790788
}

builtin/merge.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
15781578

15791579
finish(head_commit, remoteheads, &commit->object.oid, msg.buf);
15801580
remove_merge_branch_state(the_repository);
1581+
strbuf_release(&msg);
15811582
goto done;
15821583
} else if (!remoteheads->next && common->next)
15831584
;
@@ -1748,6 +1749,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
17481749
ret = suggest_conflicts();
17491750

17501751
done:
1752+
strbuf_release(&buf);
17511753
free(branch_to_free);
17521754
return ret;
17531755
}

t/helper/test-oid-array.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@ int cmd__oid_array(int argc, const char **argv)
3535
else
3636
die("unknown command: %s", line.buf);
3737
}
38+
39+
strbuf_release(&line);
40+
oid_array_clear(&array);
41+
3842
return 0;
3943
}

t/helper/test-oidtree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ int cmd__oidtree(int argc, const char **argv)
4545
die("unknown command: %s", line.buf);
4646
}
4747
}
48+
49+
strbuf_release(&line);
50+
4851
return 0;
4952
}

t/helper/test-parse-options.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ static int dry_run = 0, quiet = 0;
1414
static char *string = NULL;
1515
static char *file = NULL;
1616
static int ambiguous;
17-
static struct string_list list = STRING_LIST_INIT_NODUP;
1817

1918
static struct {
2019
int called;
@@ -107,6 +106,8 @@ int cmd__parse_options(int argc, const char **argv)
107106
NULL
108107
};
109108
struct string_list expect = STRING_LIST_INIT_NODUP;
109+
struct string_list list = STRING_LIST_INIT_NODUP;
110+
110111
struct option options[] = {
111112
OPT_BOOL(0, "yes", &boolean, "get a boolean"),
112113
OPT_BOOL('D', "no-doubt", &boolean, "begins with 'no-'"),
@@ -185,5 +186,9 @@ int cmd__parse_options(int argc, const char **argv)
185186
for (i = 0; i < argc; i++)
186187
show(&expect, &ret, "arg %02d: %s", i, argv[i]);
187188

189+
expect.strdup_strings = 1;
190+
string_list_clear(&expect, 0);
191+
string_list_clear(&list, 0);
192+
188193
return ret;
189194
}

t/helper/test-prio-queue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@ int cmd__prio_queue(int argc, const char **argv)
4646
}
4747
}
4848

49+
clear_prio_queue(&pq);
50+
4951
return 0;
5052
}

t/t0009-prio-queue.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='basic tests for priority queue implementation'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
cat >expect <<'EOF'

t/t0040-parse-options.sh

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

66
test_description='our own option parser'
77

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

1011
cat >expect <<\EOF

t/t0064-oid-array.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='basic tests for the oid array implementation'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
echoid () {

t/t0069-oidtree.sh

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

33
test_description='basic tests for the oidtree implementation'
4+
TEST_PASSES_SANITIZE_LEAK=true
45
. ./test-lib.sh
56

67
maxhexsz=$(test_oid hexsz)

0 commit comments

Comments
 (0)