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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
							parent
							
								
									fa016423c7
								
							
						
					
					
						commit
						12dfc2475c
					
				| 
						 | 
				
			
			@ -266,8 +266,8 @@ static void merge_broken(struct diff_filepair *p,
 | 
			
		|||
	 * in the resulting tree.
 | 
			
		||||
	 */
 | 
			
		||||
	d->one->rename_used++;
 | 
			
		||||
	diff_free_filespec_data(d->two);
 | 
			
		||||
	diff_free_filespec_data(c->one);
 | 
			
		||||
	free_filespec(d->two);
 | 
			
		||||
	free_filespec(c->one);
 | 
			
		||||
	free(d);
 | 
			
		||||
	free(c);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,8 @@ With -B, this should be detected as two complete rewrites.
 | 
			
		|||
 | 
			
		||||
Further, with -B and -M together, these should turn into two renames.
 | 
			
		||||
'
 | 
			
		||||
 | 
			
		||||
TEST_PASSES_SANITIZE_LEAK=true
 | 
			
		||||
. ./test-lib.sh
 | 
			
		||||
. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
 | 
			
		||||
test_description='rewrite diff'
 | 
			
		||||
 | 
			
		||||
TEST_PASSES_SANITIZE_LEAK=true
 | 
			
		||||
. ./test-lib.sh
 | 
			
		||||
. "$TEST_DIRECTORY"/lib-diff-data.sh
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
 | 
			
		||||
test_description='typechange rename detection'
 | 
			
		||||
 | 
			
		||||
TEST_PASSES_SANITIZE_LEAK=true
 | 
			
		||||
. ./test-lib.sh
 | 
			
		||||
. "$TEST_DIRECTORY"/lib-diff.sh
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,6 +2,7 @@
 | 
			
		|||
 | 
			
		||||
test_description='rewrite diff on binary file'
 | 
			
		||||
 | 
			
		||||
TEST_PASSES_SANITIZE_LEAK=true
 | 
			
		||||
. ./test-lib.sh
 | 
			
		||||
 | 
			
		||||
# We must be large enough to meet the MINIMUM_BREAK_SIZE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,8 @@
 | 
			
		|||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
test_description='git commit summary'
 | 
			
		||||
 | 
			
		||||
TEST_PASSES_SANITIZE_LEAK=true
 | 
			
		||||
. ./test-lib.sh
 | 
			
		||||
 | 
			
		||||
test_expect_success 'setup' '
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue