We have an execution path in apply_data that leaks the local struct
image.  Plug it.
This leak can be triggered with:
    $ echo foo >file
    $ git add file && git commit -m file
    $ echo bar >file
    $ git diff file >diff
    $ sed s/foo/frotz/ <diff >baddiff
    $ git apply --cached <baddiff
Fixing this leak allows us to mark as leak-free the following tests:
    + t2016-checkout-patch.sh
    + t4103-apply-binary.sh
    + t4104-apply-boundary.sh
    + t4113-apply-ending.sh
    + t4117-apply-reject.sh
    + t4123-apply-shrink.sh
    + t4252-am-options.sh
    + t4258-am-quoted-cr.sh
Mark them with "TEST_PASSES_SANITIZE_LEAK=true" to notice and fix
promply any new leak that may be introduced and triggered by them in the
future.
Signed-off-by: Rubén Justo <rjusto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
		
	
		
			
				
	
	
		
			48 lines
		
	
	
		
			509 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			509 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/sh
 | 
						|
 | 
						|
test_description='apply a patch that is larger than the preimage'
 | 
						|
 | 
						|
TEST_PASSES_SANITIZE_LEAK=true
 | 
						|
. ./test-lib.sh
 | 
						|
 | 
						|
cat >F  <<\EOF
 | 
						|
1
 | 
						|
2
 | 
						|
3
 | 
						|
4
 | 
						|
5
 | 
						|
6
 | 
						|
7
 | 
						|
8
 | 
						|
999999
 | 
						|
A
 | 
						|
B
 | 
						|
C
 | 
						|
D
 | 
						|
E
 | 
						|
F
 | 
						|
G
 | 
						|
H
 | 
						|
I
 | 
						|
J
 | 
						|
 | 
						|
EOF
 | 
						|
 | 
						|
test_expect_success setup '
 | 
						|
 | 
						|
	git add F &&
 | 
						|
	mv F G &&
 | 
						|
	sed -e "s/1/11/" -e "s/999999/9/" -e "s/H/HH/" <G >F &&
 | 
						|
	git diff >patch &&
 | 
						|
	sed -e "/^\$/d" <G >F &&
 | 
						|
	git add F
 | 
						|
 | 
						|
'
 | 
						|
 | 
						|
test_expect_success 'apply should fail gracefully' '
 | 
						|
	test_must_fail git apply --index patch &&
 | 
						|
	test_path_is_missing .git/index.lock
 | 
						|
'
 | 
						|
 | 
						|
test_done
 |