Skip to content

Commit 36f971f

Browse files
pks-tgitster
authored andcommitted
diff: free state populated via options
The `objfind` and `anchors` members of `struct diff_options` are populated via option parsing, but are never freed in `diff_free()`. Fix this to plug those memory leaks. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0aaca0e commit 36f971f

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

diff.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6717,6 +6717,16 @@ void diff_free(struct diff_options *options)
67176717
if (options->no_free)
67186718
return;
67196719

6720+
if (options->objfind) {
6721+
oidset_clear(options->objfind);
6722+
FREE_AND_NULL(options->objfind);
6723+
}
6724+
6725+
for (size_t i = 0; i < options->anchors_nr; i++)
6726+
free(options->anchors[i]);
6727+
FREE_AND_NULL(options->anchors);
6728+
options->anchors_nr = options->anchors_alloc = 0;
6729+
67206730
diff_free_file(options);
67216731
diff_free_ignore_regex(options);
67226732
clear_pathspec(&options->pathspec);

t/t4064-diff-oidfind.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='test finding specific blobs in the revision walking'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup ' '

t/t4065-diff-anchored.sh

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

33
test_description='anchored diff algorithm'
44

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

78
test_expect_success '--anchored' '

t/t4069-remerge-diff.sh

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

33
test_description='remerge-diff handling'
44

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

78
# This test is ort-specific

0 commit comments

Comments
 (0)