Skip to content

Commit 12dfc24

Browse files
pks-tgitster
authored andcommitted
diffcore-break: fix leaking filespecs when merging broken pairs
When merging file pairs after they have been broken up we queue a new file pair and discard the broken-up ones. The newly-queued file pair reuses one filespec of the broken up pairs each, where the respective other filespec gets discarded. But we only end up freeing the filespec's data, not the filespec itself, and thus leak memory. Fix these leaks by using `free_filespec()` instead. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fa01642 commit 12dfc24

6 files changed

+9
-2
lines changed

diffcore-break.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ static void merge_broken(struct diff_filepair *p,
266266
* in the resulting tree.
267267
*/
268268
d->one->rename_used++;
269-
diff_free_filespec_data(d->two);
270-
diff_free_filespec_data(c->one);
269+
free_filespec(d->two);
270+
free_filespec(c->one);
271271
free(d);
272272
free(c);
273273
}

t/t4008-diff-break-rewrite.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ With -B, this should be detected as two complete rewrites.
2121
2222
Further, with -B and -M together, these should turn into two renames.
2323
'
24+
25+
TEST_PASSES_SANITIZE_LEAK=true
2426
. ./test-lib.sh
2527
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
2628

t/t4022-diff-rewrite.sh

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

33
test_description='rewrite diff'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-diff-data.sh
78

t/t4023-diff-rename-typechange.sh

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

33
test_description='typechange rename detection'
44

5+
TEST_PASSES_SANITIZE_LEAK=true
56
. ./test-lib.sh
67
. "$TEST_DIRECTORY"/lib-diff.sh
78

t/t4031-diff-rewrite-binary.sh

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

33
test_description='rewrite diff on binary file'
44

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

78
# We must be large enough to meet the MINIMUM_BREAK_SIZE

t/t7524-commit-summary.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='git commit summary'
4+
5+
TEST_PASSES_SANITIZE_LEAK=true
46
. ./test-lib.sh
57

68
test_expect_success 'setup' '

0 commit comments

Comments
 (0)